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) {
277 Dumper($form->{"pricegroup_id_$i"}));
279 qq|<option value="$form->{"sellprice_$i"}--$form->{"pricegroup_id_$i"}" selected>$form->{"pricegroup_$i"}</option>\n|;
281 $form->{"pricegroup_old_$i"} = $form->{"pricegroup_id_$i"};
283 $column_data{sellprice_drag} =
284 qq|<td align=right><select name="sellprice_drag_$i">$prices</select></td>|;
288 $column_data{sellprice_drag} =
289 qq|<td align=right><input name="sellprice_$i" size=9 value=|
290 . $form->format_amount(\%myconfig, $form->{"prices_$i"},
295 $column_data{sellprice} =
296 qq|<td><input name="sellprice_$i" size=5 value=|
297 . $form->format_amount(\%myconfig, $form->{"sellprice_$i"},
301 $column_data{discount} =
302 qq|<td align=right><input name="discount_$i" size=3 value=|
303 . $form->format_amount(\%myconfig, $form->{"discount_$i"})
305 $column_data{linetotal} =
307 . $form->format_amount(\%myconfig, $linetotal, 2)
309 $column_data{bin} = qq|<td>$form->{"bin_$i"}</td>|;
311 ########################################
312 # Eintrag fuer Version 2.2.0 geaendert #
313 # neue Optik im Rechnungsformular #
314 ########################################
315 # if ($lizenzen && $form->{type} eq "invoice" && $form->{vc} eq "customer") {
316 # $column_data{license} = qq|<td><select name="licensenumber_$i">$form->{"lizenzen_$i"}></select></td>|;
319 # if ($form->{type} !~ /_quotation/) {
320 # $column_data{serialnr} = qq|<td><input name="serialnumber_$i" size=10 value="$form->{"serialnumber_$i"}"></td>|;
323 # $column_data{projectnr} = qq|<td><input name="projectnumber_$i" size=10 value="$form->{"projectnumber_$i"}"></td>|;
324 ############## ENDE Neueintrag ##################
329 map { print "\n$column_data{$_}" } @column_index;
334 <input type=hidden name="orderitems_id_$i" value=$form->{"orderitems_id_$i"}>
335 <input type=hidden name="bo_$i" value=$form->{"bo_$i"}>
337 <input type=hidden name="pricegroup_old_$i" value=$form->{"pricegroup_old_$i"}>
338 <input type=hidden name="price_old_$i" value=$form->{"price_old_$i"}>
339 <input type=hidden name="price_new_$i" value=|.$form->format_amount(\%myconfig,$form->{"price_new_$i"}).qq|>
341 <input type=hidden name="id_$i" value=$form->{"id_$i"}>
342 <input type=hidden name="inventory_accno_$i" value=$form->{"inventory_accno_$i"}>
343 <input type=hidden name="bin_$i" value="$form->{"bin_$i"}">
344 <input type=hidden name="partsgroup_$i" value="$form->{"partsgroup_$i"}">
345 <input type=hidden name="partnotes_$i" value="$form->{"partnotes_$i"}">
346 <input type=hidden name="income_accno_$i" value=$form->{"income_accno_$i"}>
347 <input type=hidden name="expense_accno_$i" value=$form->{"expense_accno_$i"}>
348 <input type=hidden name="listprice_$i" value="$form->{"listprice_$i"}">
349 <input type=hidden name="assembly_$i" value="$form->{"assembly_$i"}">
350 <input type=hidden name="taxaccounts_$i" value="$form->{"taxaccounts_$i"}">
354 ########################################
355 # Eintrag fuer Version 2.2.0 geaendert #
356 # neue Optik im Rechnungsformular #
357 ########################################
361 <td colspan=$colspan>
363 if ($lizenzen && $form->{type} eq "invoice" && $form->{vc} eq "customer") {
364 my $selected = $form->{"licensenumber_$i"};
366 $form->{"lizenzen_$i"} =~ s/ selected//g;
367 $form->{"lizenzen_$i"} =~
368 s/value="${selected}"\>/value="${selected}" selected\>/;
369 $lizenzen_quoted = $form->{"lizenzen_$i"};
370 $lizenzen_quoted =~ s/\"/"/g;
372 <b>Lizenz\#</b> <select name="licensenumber_$i" size=1>
373 $form->{"lizenzen_$i"}
375 <input type=hidden name="lizenzen_$i" value="${lizenzen_quoted}">
378 if ($form->{type} !~ /_quotation/) {
380 <b>$serialnumber</b> <input name="serialnumber_$i" size=15 value="$form->{"serialnumber_$i"}">|;
384 <b>$projectnumber</b> <input name="projectnumber_$i" size=10 value="$form->{"projectnumber_$i"}">
385 <input type=hidden name="oldprojectnumber_$i" value="$form->{"oldprojectnumber_$i"}">
386 <input type=hidden name="project_id_$i" value="$form->{"project_id_$i"}">
392 ############## ENDE Neueintrag ##################
394 map { $form->{"${_}_base"} += $linetotal }
395 (split / /, $form->{"taxaccounts_$i"});
397 $form->{invsubtotal} += $linetotal;
406 $lxdebug->leave_sub();
409 ##################################################
410 # build html-code for pricegroups in variable $form->{prices_$j}
413 my $rowcount = shift;
414 $lxdebug->enter_sub();
415 for $j (1 .. $rowcount) {
417 my $pricegroup_old = $form->{"pricegroup_old_$i"};
418 if ($form->{PRICES}{ $j }) {
422 foreach $item (@{ $form->{PRICES}{ $j } }) {
423 $price = $form->round_amount($myconfig, $item->{price},5);
424 $price = $form->format_amount($myconfig, $item->{price},2);
425 $price = $item->{price};
426 $pricegroup_id = $item->{pricegroup_id};
427 $pricegroup = $item->{pricegroup};
428 # build dragdrop for pricegroups
430 qq|<option value="$price--$pricegroup_id"$item->{selected}>$pricegroup</option>\n|;
433 # set new selectedpricegroup_id and prices for "Preis"
434 if ($item->{selected}) {
435 $form->{"pricegroup_old_$j"} = $pricegroup_id;
436 $form->{"price_new_$j"} = $price;
437 $form->{"sellprice_$j"} = $price;
440 $form->{"prices_$j"} = $prices;
445 $lxdebug->leave_sub();
449 $lxdebug->enter_sub();
450 @column_index = qw(ndx partnumber description onhand sellprice);
452 $column_data{ndx} = qq|<th> </th>|;
453 $column_data{partnumber} =
454 qq|<th class=listheading>| . $locale->text('Number') . qq|</th>|;
455 $column_data{description} =
456 qq|<th class=listheading>| . $locale->text('Part Description') . qq|</th>|;
457 $column_data{sellprice} =
458 qq|<th class=listheading>| . $locale->text('Price') . qq|</th>|;
459 $column_data{onhand} =
460 qq|<th class=listheading>| . $locale->text('Qty') . qq|</th>|;
462 # list items with radio button on a form
465 $title = $locale->text('Select from one of the items below');
466 $colspan = $#column_index + 1;
471 <form method=post action=$form->{script}>
475 <th class=listtop colspan=$colspan>$title</th>
478 <tr class=listheading>|;
480 map { print "\n$column_data{$_}" } @column_index;
485 foreach $ref (@{ $form->{item_list} }) {
486 $checked = ($i++) ? "" : "checked";
489 if ($ref->{inventory_accno} > 0) {
490 $ref->{"lizenzen"} = qq|<option></option>|;
491 foreach $item (@{ $form->{LIZENZEN}{ $ref->{"id"} } }) {
492 $ref->{"lizenzen"} .=
493 qq|<option value=\"$item->{"id"}\">$item->{"licensenumber"}</option>|;
495 $ref->{"lizenzen"} .= qq|<option value=-1>Neue Lizenz</option>|;
496 $ref->{"lizenzen"} =~ s/\"/"/g;
500 map { $ref->{$_} =~ s/\"/"/g } qw(partnumber description unit);
503 $form->round_amount($ref->{sellprice} * (1 - $form->{tradediscount}), 2);
505 qq|<td><input name=ndx class=radio type=radio value=$i $checked></td>|;
506 $column_data{partnumber} =
507 qq|<td><input name="new_partnumber_$i" type=hidden value="$ref->{partnumber}">$ref->{partnumber}</td>|;
508 $column_data{description} =
509 qq|<td><input name="new_description_$i" type=hidden value="$ref->{description}">$ref->{description}</td>|;
510 $column_data{sellprice} =
511 qq|<td align=right><input name="new_sellprice_$i" type=hidden value=$ref->{sellprice}>|
512 . $form->format_amount(\%myconfig, $ref->{sellprice}, 2, " ")
514 $column_data{onhand} =
515 qq|<td align=right><input name="new_onhand_$i" type=hidden value=$ref->{onhand}>|
516 . $form->format_amount(\%myconfig, $ref->{onhand}, '', " ")
522 <tr class=listrow$j>|;
524 map { print "\n$column_data{$_}" } @column_index;
529 <input name="new_bin_$i" type=hidden value="$ref->{bin}">
530 <input name="new_listprice_$i" type=hidden value=$ref->{listprice}>
531 <input name="new_inventory_accno_$i" type=hidden value=$ref->{inventory_accno}>
532 <input name="new_income_accno_$i" type=hidden value=$ref->{income_accno}>
533 <input name="new_expense_accno_$i" type=hidden value=$ref->{expense_accno}>
534 <input name="new_unit_$i" type=hidden value="$ref->{unit}">
535 <input name="new_weight_$i" type=hidden value="$ref->{weight}">
536 <input name="new_assembly_$i" type=hidden value="$ref->{assembly}">
537 <input name="new_taxaccounts_$i" type=hidden value="$ref->{taxaccounts}">
538 <input name="new_partsgroup_$i" type=hidden value="$ref->{partsgroup}">
540 <input name="new_id_$i" type=hidden value=$ref->{id}>
545 <input name="new_lizenzen_$i" type=hidden value="$ref->{lizenzen}">
552 <tr><td colspan=8><hr size=3 noshade></td></tr>
555 <input name=lastndx type=hidden value=$i>
559 # delete action variable
560 map { delete $form->{$_} } qw(action item_list header);
562 # save all other form variables
563 foreach $key (keys %${form}) {
564 $form->{$key} =~ s/\"/"/g;
565 print qq|<input name=$key type=hidden value="$form->{$key}">\n|;
569 <input type=hidden name=nextsub value=item_selected>
572 <input class=submit type=submit name=action value="|
573 . $locale->text('Continue') . qq|">
580 $lxdebug->leave_sub();
584 $lxdebug->enter_sub();
585 # replace the last row with the checked row
586 $i = $form->{rowcount};
587 $i = $form->{assembly_rows} if ($form->{item} eq 'assembly');
593 #($form->{"sellprice_$i"},$form->{"$pricegroup_old_$i"}) = split /--/, $form->{"sellprice_$i"};
594 #$form->{"sellprice_$i"} = $form->{"sellprice_$i"};
596 # if there was a price entered, override it
597 $sellprice = $form->parse_amount(\%myconfig, $form->{"sellprice_$i"});
599 map { $form->{"${_}_$i"} = $form->{"new_${_}_$j"} }
600 qw(id partnumber description sellprice listprice inventory_accno income_accno expense_accno bin unit weight assembly taxaccounts partsgroup);
603 map { $form->{"${_}_$i"} = $form->{"new_${_}_$j"} } qw(lizenzen);
606 ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/);
608 $decimalplaces = ($dec > 2) ? $dec : 2;
611 $form->{"sellprice_$i"} = $sellprice;
614 # if there is an exchange rate adjust sellprice
615 if (($form->{exchangerate} * 1) != 0) {
616 $form->{"sellprice_$i"} /= $form->{exchangerate};
617 $form->{"sellprice_$i"} =
618 $form->round_amount($form->{"sellprice_$i"}, $decimalplaces);
622 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
623 qw(sellprice listprice weight);
625 $form->{sellprice} += ($form->{"sellprice_$i"} * $form->{"qty_$i"});
626 $form->{weight} += ($form->{"weight_$i"} * $form->{"qty_$i"});
629 $form->{"sellprice_$i"} * (1 - $form->{"discount_$i"} / 100) *
631 map { $form->{"${_}_base"} += $amount }
632 (split / /, $form->{"taxaccounts_$i"});
633 map { $amount += ($form->{"${_}_base"} * $form->{"${_}_rate"}) } split / /,
634 $form->{"taxaccounts_$i"}
635 if !$form->{taxincluded};
637 $form->{creditremaining} -= $amount;
639 $form->{"runningnumber_$i"} = $i;
641 # delete all the new_ variables
642 for $i (1 .. $form->{lastndx}) {
643 map { delete $form->{"new_${_}_$i"} }
644 qw(partnumber description sellprice bin listprice inventory_accno income_accno expense_accno unit assembly taxaccounts id);
647 map { delete $form->{$_} } qw(ndx lastndx nextsub);
652 $form->format_amount(\%myconfig, $form->{"${_}_$i"}, $decimalplaces)
653 } qw(sellprice listprice) if $form->{item} ne 'assembly';
655 # get pricegroups for parts
656 IS->get_pricegroups_for_parts(\%myconfig, \%$form);
658 # build up html code for prices_$i
663 $lxdebug->leave_sub();
667 $lxdebug->enter_sub();
670 $form->{old_callback} = $form->escape($form->{callback}, 1);
671 $form->{callback} = $form->escape("$form->{script}?action=display_form", 1);
674 delete $form->{action};
676 # save all other form variables in a previousform variable
677 foreach $key (keys %$form) {
680 $form->{$key} =~ s/&/%26/g;
681 $previousform .= qq|$key=$form->{$key}&|;
684 $previousform = $form->escape($previousform, 1);
686 $i = $form->{rowcount};
687 map { $form->{"${_}_$i"} =~ s/\"/"/g } qw(partnumber description);
694 <h4 class=error>| . $locale->text('Item not on file!') . qq|
697 | . $locale->text('What type of item is this?') . qq|</h4>
699 <form method=post action=ic.pl>
703 <input class=radio type=radio name=item value=part checked> |
704 . $locale->text('Part') . qq|<br>
705 <input class=radio type=radio name=item value=service> |
706 . $locale->text('Service')
709 <input type=hidden name=previousform value="$previousform">
710 <input type=hidden name=partnumber value="$form->{"partnumber_$i"}">
711 <input type=hidden name=description value="$form->{"description_$i"}">
712 <input type=hidden name=rowcount value=$form->{rowcount}>
713 <input type=hidden name=taxaccount2 value=$form->{taxaccounts}>
714 <input type=hidden name=vc value=$form->{vc}>
716 <input type=hidden name=path value=$form->{path}>
717 <input type=hidden name=login value=$form->{login}>
718 <input type=hidden name=password value=$form->{password}>
720 <input type=hidden name=nextsub value=add>
723 <input class=submit type=submit name=action value="|
724 . $locale->text('Continue') . qq|">
731 $lxdebug->leave_sub();
735 $lxdebug->enter_sub();
737 # if we have a display_form
738 if ($form->{display_form}) {
739 &{"$form->{display_form}"};
742 if ( $form->{print_and_post}
743 && $form->{second_run}
744 && ($form->{action} eq "display_form")) {
745 for (keys %$form) { $old_form->{$_} = $form->{$_} }
746 $old_form->{rowcount}++;
748 #$form->{rowcount}--;
749 #$form->{rowcount}--;
751 $form->{print_and_post} = 0;
753 &print_form($old_form);
757 $form->{action} = "";
758 $form->{resubmit} = 0;
760 if ($form->{print_and_post} && !$form->{second_run}) {
761 $form->{second_run} = 1;
762 $form->{action} = "display_form";
764 my $rowcount = $form->{rowcount};
765 # get pricegroups for parts
766 IS->get_pricegroups_for_parts(\%myconfig, \%$form, "new");
767 # build up html code for prices_$i
768 set_pricegroup($rowcount);
771 $form->{resubmit} = 1;
776 $numrows = ++$form->{rowcount};
777 $subroutine = "display_row";
779 if ($form->{item} eq 'part') {
780 #set preisgruppenanzahl
781 $numrows = $form->{price_rows};
782 $subroutine = "price_row";
784 &{$subroutine}($numrows);
786 $numrows = ++$form->{makemodel_rows};
787 $subroutine = "makemodel_row";
789 if ($form->{item} eq 'assembly') {
790 $numrows = ++$form->{price_rows};
791 $subroutine = "price_row";
793 &{$subroutine}($numrows);
795 $numrows = ++$form->{makemodel_rows};
796 $subroutine = "makemodel_row";
798 # create makemodel rows
799 &{$subroutine}($numrows);
801 $numrows = ++$form->{assembly_rows};
802 $subroutine = "assembly_row";
804 if ($form->{item} eq 'service') {
805 $numrows = ++$form->{price_rows};
806 $subroutine = "price_row";
808 &{$subroutine}($numrows);
814 &{$subroutine}($numrows) if $numrows;
818 $lxdebug->leave_sub();
822 $lxdebug->enter_sub();
826 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)
829 # remove any makes or model rows
830 if ($form->{item} eq 'part') {
831 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
832 qw(listprice sellprice lastcost weight rop);
834 @flds = (make, model);
835 for my $i (1 .. ($form->{makemodel_rows})) {
836 if (($form->{"make_$i"} ne "") || ($form->{"model_$i"} ne "")) {
840 map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
845 $form->redo_rows(\@flds, \@a, $count, $form->{makemodel_rows});
846 $form->{makemodel_rows} = $count;
848 } elsif ($form->{item} eq 'assembly') {
850 $form->{sellprice} = 0;
852 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
853 qw(listprice rop stock);
856 qw(id qty unit bom partnumber description sellprice weight runningnumber partsgroup);
858 for my $i (1 .. ($form->{assembly_rows} - 1)) {
859 if ($form->{"qty_$i"}) {
863 $form->{"qty_$i"} = $form->parse_amount(\%myconfig, $form->{"qty_$i"});
865 map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
867 #($form->{"sellprice_$i"},$form->{"$pricegroup_old_$i"}) = split /--/, $form->{"sellprice_$i"};
869 $form->{sellprice} += ($form->{"qty_$i"} * $form->{"sellprice_$i"});
870 $form->{weight} += ($form->{"qty_$i"} * $form->{"weight_$i"});
875 $form->{sellprice} = $form->round_amount($form->{sellprice}, 2);
877 $form->redo_rows(\@flds, \@a, $count, $form->{assembly_rows});
878 $form->{assembly_rows} = $count;
881 @flds = qw(make model);
884 for my $i (1 .. ($form->{makemodel_rows})) {
885 if (($form->{"make_$i"} ne "") || ($form->{"model_$i"} ne "")) {
889 map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
894 $form->redo_rows(\@flds, \@a, $count, $form->{makemodel_rows});
895 $form->{makemodel_rows} = $count;
899 # this section applies to invoices and orders
900 # remove any empty numbers
901 if ($form->{rowcount}) {
902 for my $i (1 .. $form->{rowcount} - 1) {
903 if ($form->{"partnumber_$i"}) {
907 map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
910 if ($form->{"licensenumber_$i"} == -1) {
918 $form->redo_rows(\@flds, \@a, $count, $form->{rowcount});
919 $form->{rowcount} = $count;
921 $form->{creditremaining} -= &invoicetotal;
928 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/)) {
930 # get pricegroups for parts
931 IS->get_pricegroups_for_parts(\%myconfig, \%$form);
933 # build up html code for prices_$i
940 $lxdebug->leave_sub();
944 $lxdebug->enter_sub();
946 $form->{oldinvtotal} = 0;
948 # add all parts and deduct paid
949 map { $form->{"${_}_base"} = 0 } split / /, $form->{taxaccounts};
951 my ($amount, $sellprice, $discount, $qty);
953 for my $i (1 .. $form->{rowcount}) {
954 $sellprice = $form->parse_amount(\%myconfig, $form->{"sellprice_$i"});
955 $discount = $form->parse_amount(\%myconfig, $form->{"discount_$i"});
956 $qty = $form->parse_amount(\%myconfig, $form->{"qty_$i"});
958 #($form->{"sellprice_$i"}, $form->{"$pricegroup_old_$i"}) = split /--/, $form->{"sellprice_$i"};
960 $amount = $sellprice * (1 - $discount / 100) * $qty;
961 map { $form->{"${_}_base"} += $amount }
962 (split / /, $form->{"taxaccounts_$i"});
963 $form->{oldinvtotal} += $amount;
966 map { $form->{oldinvtotal} += ($form->{"${_}_base"} * $form->{"${_}_rate"}) }
967 split / /, $form->{taxaccounts}
968 if !$form->{taxincluded};
970 $form->{oldtotalpaid} = 0;
971 for $i (1 .. $form->{paidaccounts}) {
972 $form->{oldtotalpaid} += $form->{"paid_$i"};
975 $lxdebug->leave_sub();
978 return ($form->{oldinvtotal} - $form->{oldtotalpaid});
982 $lxdebug->enter_sub();
983 # check if items are valid
984 if ($form->{rowcount} == 1) {
989 for $i (1 .. $form->{rowcount} - 1) {
990 $form->isblank("partnumber_$i",
991 $locale->text('Number missing in Row') . " $i");
994 $lxdebug->leave_sub();
998 $lxdebug->enter_sub();
999 if ($form->{second_run}) {
1000 $form->{print_and_post} = 0;
1002 $form->{ordnumber} = $form->{invnumber};
1004 map { delete $form->{$_} } qw(id printed emailed queued);
1005 if ($form->{script} eq 'ir.pl' || $form->{type} eq 'request_quotation') {
1006 $form->{title} = $locale->text('Add Purchase Order');
1007 $form->{vc} = 'vendor';
1008 $form->{type} = 'purchase_order';
1011 if ($form->{script} eq 'is.pl' || $form->{type} eq 'sales_quotation') {
1012 $form->{title} = $locale->text('Add Sales Order');
1013 $form->{vc} = 'customer';
1014 $form->{type} = 'sales_order';
1017 $form->{script} = 'oe.pl';
1019 $form->{shipto} = 1;
1021 $form->{rowcount}--;
1023 ($null, $form->{cp_id}) = split /--/, $form->{contact};
1024 $form->{cp_id} *= 1;
1026 require "$form->{path}/$form->{script}";
1028 map { $form->{"select$_"} = "" } ($form->{vc}, currency);
1030 $currency = $form->{currency};
1034 $form->{currency} = $currency;
1035 $form->{exchangerate} = "";
1036 $form->{forex} = "";
1037 $form->{exchangerate} = $exchangerate
1041 $form->check_exchangerate(
1042 \%myconfig, $form->{currency}, $form->{transdate}, $buysell
1048 $lxdebug->leave_sub();
1052 $lxdebug->enter_sub();
1053 if ($form->{second_run}) {
1054 $form->{print_and_post} = 0;
1056 map { delete $form->{$_} } qw(id printed emailed queued);
1058 if ($form->{script} eq 'ir.pl' || $form->{type} eq 'purchase_order') {
1059 $form->{title} = $locale->text('Add Request for Quotation');
1060 $form->{vc} = 'vendor';
1061 $form->{type} = 'request_quotation';
1064 if ($form->{script} eq 'is.pl' || $form->{type} eq 'sales_order') {
1065 $form->{title} = $locale->text('Add Quotation');
1066 $form->{vc} = 'customer';
1067 $form->{type} = 'sales_quotation';
1071 ($null, $form->{cp_id}) = split /--/, $form->{contact};
1072 $form->{cp_id} *= 1;
1074 $form->{script} = 'oe.pl';
1076 $form->{shipto} = 1;
1078 $form->{rowcount}--;
1080 require "$form->{path}/$form->{script}";
1082 map { $form->{"select$_"} = "" } ($form->{vc}, currency);
1084 $currency = $form->{currency};
1088 $form->{currency} = $currency;
1089 $form->{exchangerate} = "";
1090 $form->{forex} = "";
1091 $form->{exchangerate} = $exchangerate
1095 $form->check_exchangerate(
1096 \%myconfig, $form->{currency}, $form->{transdate}, $buysell
1102 $lxdebug->leave_sub();
1106 $lxdebug->enter_sub();
1107 if ($form->{second_run}) {
1108 $form->{print_and_post} = 0;
1109 $form->{resubmit} = 0;
1111 if ($myconfig{role} eq 'admin') {
1113 <th align=right nowrap=true>| . $locale->text('Bcc') . qq|</th>
1114 <td><input name=bcc size=30 value="$form->{bcc}"></td>
1118 if ($form->{formname} =~ /(pick|packing|bin)_list/) {
1119 $form->{email} = $form->{shiptoemail} if $form->{shiptoemail};
1122 $name = $form->{ $form->{vc} };
1124 $title = $locale->text('E-mail') . " $name";
1126 $form->{oldmedia} = $form->{media};
1127 $form->{media} = "email";
1134 <form method=post action=$form->{script}>
1138 <th class=listtop>$title</th>
1140 <tr height="5"></tr>
1145 <th align=right nowrap>| . $locale->text('To') . qq|</th>
1146 <td><input name=email size=30 value="$form->{email}"></td>
1147 <th align=right nowrap>| . $locale->text('Cc') . qq|</th>
1148 <td><input name=cc size=30 value="$form->{cc}"></td>
1151 <th align=right nowrap>| . $locale->text('Subject') . qq|</th>
1152 <td><input name=subject size=30 value="$form->{subject}"></td>
1162 <th align=left nowrap>| . $locale->text('Message') . qq|</th>
1165 <td><textarea name=message rows=15 cols=60 wrap=soft>$form->{message}</textarea></td>
1176 map { delete $form->{$_} }
1177 qw(action email cc bcc subject message formname sendmode format header override);
1179 # save all other variables
1180 foreach $key (keys %$form) {
1181 $form->{$key} =~ s/\"/"/g;
1182 print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
1189 <td><hr size=3 noshade></td>
1193 <input type=hidden name=nextsub value=send_email>
1196 <input name=action class=submit type=submit value="|
1197 . $locale->text('Continue') . qq|">
1204 $lxdebug->leave_sub();
1208 $lxdebug->enter_sub();
1210 $old_form = new Form;
1212 map { $old_form->{$_} = $form->{$_} } keys %$form;
1213 $old_form->{media} = $form->{oldmedia};
1215 &print_form($old_form);
1217 $lxdebug->leave_sub();
1221 $lxdebug->enter_sub();
1222 $form->{sendmode} = "attachment";
1223 $form->{copies} = 3 unless $form->{copies};
1225 $form->{PD}{ $form->{formname} } = "selected";
1226 $form->{DF}{ $form->{format} } = "";
1227 $form->{OP}{ $form->{media} } = "selected";
1228 $form->{SM}{ $form->{sendmode} } = "selected";
1230 if ($form->{type} eq 'purchase_order') {
1231 $type = qq|<select name=formname>
1232 <option value=purchase_order $form->{PD}{purchase_order}>|
1233 . $locale->text('Purchase Order') . qq|
1234 <option value=bin_list $form->{PD}{bin_list}>|
1235 . $locale->text('Bin List');
1238 if ($form->{type} eq 'sales_order') {
1239 $type = qq|<select name=formname>
1240 <option value=sales_order $form->{PD}{sales_order}>|
1241 . $locale->text('Confirmation') . qq|
1242 <option value=pick_list $form->{PD}{pick_list}>|
1243 . $locale->text('Pick List') . qq|
1244 <option value=packing_list $form->{PD}{packing_list}>|
1245 . $locale->text('Packing List');
1248 if ($form->{type} =~ /_quotation$/) {
1249 $type = qq|<select name=formname>
1250 <option value="$`_quotation" $form->{PD}{"$`_quotation"}>|
1251 . $locale->text('Quotation') . qq|
1255 if ($form->{type} eq 'invoice') {
1256 $type = qq|<select name=formname>
1257 <option value=invoice $form->{PD}{invoice}>| . $locale->text('Invoice');
1260 if ($form->{type} eq 'ship_order') {
1261 $type = qq|<select name=formname>
1262 <option value=pick_list $form->{PD}{pick_list}>|
1263 . $locale->text('Pick List') . qq|
1264 <option value=packing_list $form->{PD}{packing_list}>|
1265 . $locale->text('Packing List');
1268 if ($form->{type} eq 'receive_order') {
1269 $type = qq|<select name=formname>
1270 <option value=bin_list $form->{PD}{bin_list}>|
1271 . $locale->text('Bin List');
1274 if ($form->{media} eq 'email') {
1275 $media = qq|<select name=sendmode>
1276 <option value=attachment $form->{SM}{attachment}>|
1277 . $locale->text('Attachment') . qq|
1278 <option value=inline $form->{SM}{inline}>| . $locale->text('In-line');
1280 $media = qq|<select name=media>
1281 <option value=screen $form->{OP}{screen}>| . $locale->text('Screen');
1282 if ($myconfig{printer} && $latex) {
1284 <option value=printer $form->{OP}{printer}>|
1285 . $locale->text('Printer');
1289 <option value=queue $form->{OP}{queue}>| . $locale->text('Queue');
1293 $format = qq|<select name=format>
1294 <option value=html $form->{DF}{html}>html|;
1297 $format = qq|<select name=format>
1298 <option value=pdf $form->{DF}{pdf}>| . $locale->text('PDF') . qq|
1299 <option value=html $form->{DF}{html}>html
1300 <option value=postscript $form->{DF}{postscript}>|
1301 . $locale->text('Postscript');
1304 $language = qq|<select name=language>
1305 <option value=""></option>|;
1306 %lang = (de => "deutsch", en => "englisch", fr => "französisch");
1307 foreach $item (keys %lang) {
1308 if ($form->{language} eq $item) {
1309 $language .= qq|<option value="$item" selected>$lang{$item}</option>|;
1311 $language .= qq|<option value="$item">$lang{$item}</option>|;
1316 <table width=100% cellspacing=0 cellpadding=0>
1321 <td>$type</select></td>
1322 <td>$language</select</td>
1323 <td>$format</select></td>
1324 <td>$media</select></td>
1327 if ($myconfig{printer} && $latex && $form->{media} ne 'email') {
1329 <td>| . $locale->text('Copies') . qq|
1330 <input name=copies size=2 value=$form->{copies}></td>
1334 $form->{groupitems} = "checked" if $form->{groupitems};
1337 <td>| . $locale->text('Group Items') . qq|</td>
1338 <td><input name=groupitems type=checkbox class=checkbox $form->{groupitems}></td>
1347 if ($form->{printed} =~ /$form->{formname}/) {
1349 <th>\|| . $locale->text('Printed') . qq|\|</th>
1353 if ($form->{emailed} =~ /$form->{formname}/) {
1355 <th>\|| . $locale->text('E-mailed') . qq|\|</th>
1359 if ($form->{queued} =~ /$form->{formname}/) {
1361 <th>\|| . $locale->text('Queued') . qq|\|</th>
1373 $lxdebug->leave_sub();
1377 $lxdebug->enter_sub();
1378 if ($form->{second_run}) {
1379 $form->{print_and_post} = 0;
1381 # if this goes to the printer pass through
1382 if ($form->{media} eq 'printer' || $form->{media} eq 'queue') {
1383 $form->error($locale->text('Select postscript or PDF!'))
1384 if ($form->{format} !~ /(postscript|pdf)/);
1386 $old_form = new Form;
1387 map { $old_form->{$_} = $form->{$_} } keys %$form;
1390 &print_form($old_form);
1392 $lxdebug->leave_sub();
1396 $lxdebug->enter_sub();
1397 my ($old_form) = @_;
1401 $numberfld = "invnumber";
1404 ($form->{display_form}) ? $form->{display_form} : "display_form";
1406 # $form->{"notes"} will be overridden by the customer's/vendor's "notes" field. So save it here.
1407 $form->{ $form->{"formname"} . "notes" } = $form->{"notes"};
1409 if ($form->{formname} eq "invoice") {
1410 $form->{label} = $locale->text('Invoice');
1412 if ($form->{formname} eq "packing_list") {
1414 # this is from an invoice
1415 $form->{label} = $locale->text('Packing List');
1417 if ($form->{formname} eq 'sales_order') {
1420 $form->{"${inv}date"} = $form->{transdate};
1421 $form->{label} = $locale->text('Sales Order');
1422 $numberfld = "sonumber";
1425 if ($form->{formname} eq 'packing_list' && $form->{type} ne 'invoice') {
1427 # we use the same packing list as from an invoice
1430 $form->{invdate} = $form->{"${inv}date"} = $form->{transdate};
1431 $form->{label} = $locale->text('Packing List');
1434 if ($form->{formname} eq 'pick_list') {
1437 $form->{"${inv}date"} =
1438 ($form->{transdate}) ? $form->{transdate} : $form->{invdate};
1439 $form->{label} = $locale->text('Pick List');
1440 $order = 1 unless $form->{type} eq 'invoice';
1442 if ($form->{formname} eq 'purchase_order') {
1445 $form->{"${inv}date"} = $form->{transdate};
1446 $form->{label} = $locale->text('Purchase Order');
1447 $numberfld = "ponumber";
1450 if ($form->{formname} eq 'bin_list') {
1453 $form->{"${inv}date"} = $form->{transdate};
1454 $form->{label} = $locale->text('Bin List');
1457 if ($form->{formname} eq 'sales_quotation') {
1460 $form->{"${inv}date"} = $form->{transdate};
1461 $form->{label} = $locale->text('Quotation');
1462 $numberfld = "sqnumber";
1465 if ($form->{formname} eq 'request_quotation') {
1468 $form->{"${inv}date"} = $form->{transdate};
1469 $form->{label} = $locale->text('Quotation');
1470 $numberfld = "rfqnumber";
1474 $form->isblank("email", $locale->text('E-mail address missing!'))
1475 if ($form->{media} eq 'email');
1476 $form->isblank("${inv}date",
1477 $locale->text($form->{label} . ' Date missing!'));
1479 # $locale->text('Invoice Number missing!')
1480 # $locale->text('Invoice Date missing!')
1481 # $locale->text('Packing List Number missing!')
1482 # $locale->text('Packing List Date missing!')
1483 # $locale->text('Order Number missing!')
1484 # $locale->text('Order Date missing!')
1485 # $locale->text('Quotation Number missing!')
1486 # $locale->text('Quotation Date missing!')
1489 if (!$form->{"${inv}number"} && !$form->{preview}) {
1490 $form->{"${inv}number"} = $form->update_defaults(\%myconfig, $numberfld);
1491 if ($form->{media} ne 'email') {
1493 $i = $form->{rowcount};
1494 # get pricegroups for parts
1495 IS->get_pricegroups_for_parts(\%myconfig, \%$form);
1497 # build up html code for prices_$i
1500 $form->{rowcount}--;
1509 # Save the email address given in the form because it should override the setting saved for the customer/vendor.
1510 my ($saved_email, $saved_cc, $saved_bcc) =
1511 ($form->{"email"}, $form->{"cc"}, $form->{"bcc"});
1513 $language = $form->{language};
1514 &{"$form->{vc}_details"};
1515 $form->{language} = $language;
1517 $form->{"email"} = $saved_email if ($saved_email);
1518 $form->{"cc"} = $saved_cc if ($saved_cc);
1519 $form->{"bcc"} = $saved_bcc if ($saved_bcc);
1522 foreach $i (1 .. $form->{rowcount}) {
1524 ("partnumber_$i", "description_$i",
1525 "partsgroup_$i", "serialnumber_$i",
1526 "bin_$i", "unit_$i");
1528 map { push @a, "${_}_description" } split / /, $form->{taxaccounts};
1530 $ARAP = ($form->{vc} eq 'customer') ? "AR" : "AP";
1533 # format payment dates
1534 for $i (1 .. $form->{paidaccounts} - 1) {
1535 $form->{"datepaid_$i"} = $locale->date(\%myconfig, $form->{"datepaid_$i"});
1536 push @a, "${ARAP}_paid_$i", "source_$i", "memo_$i";
1539 $form->format_string(@a);
1541 ($form->{employee}) = split /--/, $form->{employee};
1542 ($form->{warehouse}, $form->{warehouse_id}) = split /--/, $form->{warehouse};
1544 # create the form variables
1546 OE->order_details(\%myconfig, \%$form);
1548 IS->invoice_details(\%myconfig, \%$form, $locale);
1551 map { $form->{$_} = $locale->date(\%myconfig, $form->{$_}, 1) }
1552 ("${inv}date", "${due}date", "shippingdate");
1554 @a = qw(name street zipcode city country);
1558 # if there is no shipto fill it in from billto
1559 foreach $item (@a) {
1560 if ($form->{"shipto$item"}) {
1567 if ( $form->{formname} eq 'purchase_order'
1568 || $form->{formname} eq 'request_quotation') {
1569 $form->{shiptoname} = $myconfig{company};
1570 $form->{shiptostreet} = $myconfig{address};
1572 map { $form->{"shipto$_"} = $form->{$_} } @a;
1576 $form->{notes} =~ s/^\s+//g;
1578 # some of the stuff could have umlauts so we translate them
1580 qw(shiptoname shiptostreet shiptozipcode shiptocity shiptocountry shiptoemail shippingpoint shipvia company address signature employee contact);
1582 push @a, ("${inv}date", "${due}date", email, cc, bcc);
1584 $form->format_string(@a);
1586 $form->{templates} = "$myconfig{templates}";
1587 if ($form->{language} ne "") {
1588 $form->{language} = "_" . $form->{language};
1591 $form->{IN} = "$form->{formname}$form->{language}.html";
1592 if ($form->{format} eq 'postscript') {
1593 $form->{postscript} = 1;
1594 $form->{IN} =~ s/html$/tex/;
1596 if ($form->{format} eq 'pdf') {
1598 $form->{IN} =~ s/html$/tex/;
1601 if ($form->{media} eq 'printer') {
1602 $form->{OUT} = "| $myconfig{printer}";
1603 $form->{printed} .= " $form->{formname}";
1604 $form->{printed} =~ s/^ //;
1606 $printed = $form->{printed};
1608 if ($form->{media} eq 'email') {
1609 $form->{subject} = qq|$form->{label} $form->{"${inv}number"}|
1610 unless $form->{subject};
1612 $form->{OUT} = "$sendmail";
1614 $form->{emailed} .= " $form->{formname}";
1615 $form->{emailed} =~ s/^ //;
1617 $emailed = $form->{emailed};
1619 if ($form->{media} eq 'queue') {
1620 %queued = split / /, $form->{queued};
1622 if ($filename = $queued{ $form->{formname} }) {
1623 $form->{queued} =~ s/$form->{formname} $filename//;
1624 unlink "$spool/$filename";
1625 $filename =~ s/\..*$//g;
1631 $filename .= ($form->{postscript}) ? '.ps' : '.pdf';
1632 $form->{OUT} = ">$spool/$filename";
1635 $form->{queued} .= " $form->{formname} $filename";
1637 $form->{queued} =~ s/^ //;
1639 $queued = $form->{queued};
1641 $form->parse_template(\%myconfig, $userspath);
1643 $form->{callback} = "";
1645 if ($form->{media} eq 'email') {
1646 $form->{message} = $locale->text('sent') unless $form->{message};
1648 $message = $form->{message};
1650 # if we got back here restore the previous form
1651 if ($form->{media} =~ /(printer|email|queue)/) {
1653 $form->update_status(\%myconfig)
1654 if ($form->{media} eq 'queue' && $form->{id});
1658 $old_form->{"${inv}number"} = $form->{"${inv}number"};
1660 # restore and display form
1661 map { $form->{$_} = $old_form->{$_} } keys %$old_form;
1663 $form->{queued} = $queued;
1664 $form->{printed} = $printed;
1665 $form->{emailed} = $emailed;
1666 $form->{message} = $message;
1668 $form->{rowcount}--;
1669 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
1670 qw(exchangerate creditlimit creditremaining);
1672 for $i (1 .. $form->{paidaccounts}) {
1674 $form->{"${_}_$i"} =
1675 $form->parse_amount(\%myconfig, $form->{"${_}_$i"})
1676 } qw(paid exchangerate);
1684 ($form->{media} eq 'printer')
1685 ? $locale->text('sent to printer')
1686 : $locale->text('emailed to') . " $form->{email}";
1687 $form->redirect(qq|$form->{label} $form->{"${inv}number"} $msg|);
1692 $lxdebug->leave_sub();
1695 sub customer_details {
1696 $lxdebug->enter_sub();
1697 IS->customer_details(\%myconfig, \%$form);
1698 $lxdebug->leave_sub();
1701 sub vendor_details {
1702 $lxdebug->enter_sub();
1704 IR->vendor_details(\%myconfig, \%$form);
1706 $lxdebug->leave_sub();
1710 $lxdebug->enter_sub();
1712 $form->{postasnew} = 1;
1713 map { delete $form->{$_} } qw(printed emailed queued);
1717 $lxdebug->leave_sub();
1721 $lxdebug->enter_sub();
1722 if ($form->{second_run}) {
1723 $form->{print_and_post} = 0;
1726 $title = $form->{title};
1727 $form->{title} = $locale->text('Ship to');
1729 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
1730 qw(exchangerate creditlimit creditremaining);
1733 # get details for name
1734 &{"$form->{vc}_details"};
1737 ($form->{vc} eq 'customer')
1738 ? $locale->text('Customer Number')
1739 : $locale->text('Vendor Number');
1741 $i = $form->{rowcount};
1742 # get pricegroups for parts
1743 IS->get_pricegroups_for_parts(\%myconfig, \%$form);
1745 # build up html code for prices_$i
1748 $nextsub = ($form->{display_form}) ? $form->{display_form} : "display_form";
1750 $form->{rowcount}--;
1757 <form method=post action=$form->{script}>
1763 <tr class=listheading>
1764 <th class=listheading colspan=2 width=50%>|
1765 . $locale->text('Billing Address') . qq|</th>
1766 <th class=listheading width=50%>|
1767 . $locale->text('Shipping Address') . qq|</th>
1769 <tr height="5"></tr>
1771 <th align=right nowrap>$number</th>
1772 <td>$form->{"$form->{vc}number"}</td>
1775 <th align=right nowrap>| . $locale->text('Company Name') . qq|</th>
1776 <td>$form->{name}</td>
1777 <td><input name=shiptoname size=35 value="$form->{shiptoname}"></td>
1780 <th align=right nowrap>| . $locale->text('Street') . qq|</th>
1781 <td>$form->{street}</td>
1782 <td><input name=shiptostreet size=35 value="$form->{shiptostreet}"></td>
1785 <th align=right nowrap>| . $locale->text('Zipcode') . qq|</th>
1786 <td>$form->{zipcode}</td>
1787 <td><input name=shiptozipcode size=35 value="$form->{shiptozipcode}"></td>
1790 <th align=right nowrap>| . $locale->text('City') . qq|</th>
1791 <td>$form->{city}</td>
1792 <td><input name=shiptocity size=35 value="$form->{shiptocity}"></td>
1795 <th align=right nowrap>| . $locale->text('Country') . qq|</th>
1796 <td>$form->{country}</td>
1797 <td><input name=shiptocountry size=35 value="$form->{shiptocountry}"></td>
1800 <th align=right nowrap>| . $locale->text('Contact') . qq|</th>
1801 <td>$form->{contact}</td>
1802 <td><input name=shiptocontact size=35 value="$form->{shiptocontact}"></td>
1805 <th align=right nowrap>| . $locale->text('Phone') . qq|</th>
1806 <td>$form->{"$form->{vc}phone"}</td>
1807 <td><input name=shiptophone size=20 value="$form->{shiptophone}"></td>
1810 <th align=right nowrap>| . $locale->text('Fax') . qq|</th>
1811 <td>$form->{"$form->{vc}fax"}</td>
1812 <td><input name=shiptofax size=20 value="$form->{shiptofax}"></td>
1815 <th align=right nowrap>| . $locale->text('E-mail') . qq|</th>
1816 <td>$form->{email}</td>
1817 <td><input name=shiptoemail size=35 value="$form->{shiptoemail}"></td>
1824 <input type=hidden name=nextsub value=$nextsub>
1828 map { delete $form->{$_} }
1829 qw(shiptoname shiptostreet shiptozipcode shiptocity shiptocountry shiptocontact shiptophone shiptofax shiptoemail header);
1830 $form->{title} = $title;
1832 foreach $key (keys %$form) {
1833 $form->{$key} =~ s/\"/"/g;
1834 print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
1842 <input class=submit type=submit name=action value="|
1843 . $locale->text('Continue') . qq|">
1850 $lxdebug->leave_sub();
1854 $lxdebug->enter_sub();
1859 $form->{old_callback} = $form->escape($form->{callback}, 1);
1860 $form->{callback} = $form->escape("$form->{script}?action=display_form", 1);
1861 $form->{old_callback} = $form->escape($form->{old_callback}, 1);
1864 delete $form->{action};
1865 $customer = $form->{customer};
1866 map { $form->{"old_$_"} = $form->{"${_}_$row"} } qw(partnumber description);
1868 # save all other form variables in a previousform variable
1869 $form->{row} = $row;
1870 foreach $key (keys %$form) {
1873 $form->{$key} =~ s/&/%26/g;
1874 $previousform .= qq|$key=$form->{$key}&|;
1877 $previousform = $form->escape($previousform, 1);
1879 $form->{script} = "licenses.pl";
1881 map { $form->{$_} = $form->{"old_$_"} } qw(partnumber description);
1882 map { $form->{$_} = $form->escape($form->{$_}, 1) }
1883 qw(partnumber description);
1885 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|;
1888 $lxdebug->leave_sub();