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/)
107 or (($form->{level} =~ /Sales/) and ($form->{type} =~ /invoice/))
108 or (($form->{level} eq undef) and ($form->{type} =~ /invoice/))
109 or ($form->{type} =~ /sales_order/)) {
110 push @column_index, qw(sellprice_drag);
113 push @column_index, qw(sellprice);
115 if ($form->{vc} eq 'customer') {
116 push @column_index, qw(discount);
119 push @column_index, "linetotal";
121 my $colspan = $#column_index + 1;
123 $form->{invsubtotal} = 0;
124 map { $form->{"${_}_base"} = 0 } (split / /, $form->{taxaccounts});
126 ########################################
127 # Eintrag fuer Version 2.2.0 geaendert #
128 # neue Optik im Rechnungsformular #
129 ########################################
130 $column_data{runningnumber} =
131 qq|<th align=left nowrap width=5 class=listheading>|
132 . $locale->text('No.')
134 $column_data{partnumber} =
135 qq|<th align=left nowrap width=12 class=listheading>|
136 . $locale->text('Number')
138 $column_data{description} =
139 qq|<th align=left nowrap width=30 class=listheading>|
140 . $locale->text('Part Description')
143 qq|<th align=left nowrap width=5 class=listheading>|
144 . $locale->text('Ship')
147 qq|<th align=left nowrap width=5 class=listheading>|
148 . $locale->text('Qty')
151 qq|<th align=left nowrap width=5 class=listheading>|
152 . $locale->text('Unit')
154 $column_data{license} =
155 qq|<th align=left nowrap width=10 class=listheading>|
156 . $locale->text('License')
158 $column_data{serialnr} =
159 qq|<th align=left nowrap width=10 class=listheading>|
160 . $locale->text('Serial No.')
162 $column_data{projectnr} =
163 qq|<th align=left nowrap width=10 class=listheading>|
164 . $locale->text('Project')
166 $column_data{sellprice} =
167 qq|<th align=left nowrap width=15 class=listheading>|
168 . $locale->text('Price')
170 $column_data{sellprice_drag} =
171 qq|<th align=left nowrap width=15 class=listheading>|
172 . $locale->text('Pricegroup')
174 $column_data{discount} =
175 qq|<th align=left class=listheading>|
176 . $locale->text('Discount')
178 $column_data{linetotal} =
179 qq|<th align=left nowrap width=10 class=listheading>|
180 . $locale->text('Extended')
183 qq|<th align=left nowrap width=10 class=listheading>|
184 . $locale->text('Bin')
186 ############## ENDE Neueintrag ##################
192 <tr class=listheading>|;
194 map { print "\n$column_data{$_}" } @column_index;
200 $runningnumber = $locale->text('No.');
201 $deliverydate = $locale->text('Delivery Date');
202 $serialnumber = $locale->text('Serial No.');
203 $projectnumber = $locale->text('Project');
204 $partsgroup = $locale->text('Group');
206 $delvar = 'deliverydate';
208 if ($form->{type} =~ /_order$/ || $form->{type} =~ /_quotation$/) {
209 $deliverydate = $locale->text('Required by');
213 for $i (1 .. $numrows) {
218 $form->parse_amount(\%myconfig, $form->{"${_}_$i"})
219 } qw(qty ship discount sellprice price_new price_old);
221 ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/);
223 $decimalplaces = ($dec > 2) ? $dec : 2;
227 $form->{"sellprice_$i"} * $form->{"discount_$i"} / 100,
231 $form->round_amount($form->{"sellprice_$i"} - $discount, $decimalplaces);
232 $linetotal = $form->round_amount($linetotal * $form->{"qty_$i"}, 2);
234 # convert " to "
235 map { $form->{"${_}_$i"} =~ s/\"/"/g }
236 qw(partnumber description unit);
238 ########################################
239 # Eintrag fuer Version 2.2.0 geaendert #
240 # neue Optik im Rechnungsformular #
241 ########################################
242 $column_data{runningnumber} =
243 qq|<td><input name="runningnumber_$i" size=5 value=$i></td>|; # HuT
244 ############## ENDE Neueintrag ##################
246 $column_data{partnumber} =
247 qq|<td><input name="partnumber_$i" size=12 value="$form->{"partnumber_$i"}"></td>|;
249 if (($rows = $form->numtextrows($form->{"description_$i"}, 30, 6)) > 1) {
250 $column_data{description} =
251 qq|<td><textarea name="description_$i" rows=$rows cols=30 wrap=soft>$form->{"description_$i"}</textarea></td>|;
253 $column_data{description} =
254 qq|<td><input name="description_$i" size=30 value="$form->{"description_$i"}"></td>|;
257 (my $qty_dec) = ($form->{"qty_$i"} =~ /\.(\d+)/);
258 $qty_dec = length $qty_dec;
261 qq|<td align=right><input name="qty_$i" size=5 value=|
262 . $form->format_amount(\%myconfig, $form->{"qty_$i"}, $qty_dec)
265 qq|<td align=right><input name="ship_$i" size=5 value=|
266 . $form->format_amount(\%myconfig, $form->{"ship_$i"})
269 qq|<td><input name="unit_$i" size=5 value="$form->{"unit_$i"}"></td>|;
271 # build in dragdrop for pricesgroups
272 if ($form->{"prices_$i"}) {
274 $form->format_amount(\%myconfig, $form->{"price_new_$i"}, 2);
276 $column_data{sellprice_drag} =
277 qq|<td align=right><select name="sellprice_drag_$i">$form->{"prices_$i"}</select></td>|;
278 $column_data{sellprice} =
279 qq|<td><input name="sellprice_$i" size=5 value=$price_tmp></td>|;
282 # for last row and report
283 # set pricegroup dragdrop from report menu
284 if ($form->{"sellprice_$i"} != 0) {
286 qq|<option value="$form->{"sellprice_$i"}--$form->{"pricegroup_id_$i"}" selected>$form->{"pricegroup_$i"}</option>\n|;
288 $form->{"pricegroup_old_$i"} = $form->{"pricegroup_id_$i"};
290 $column_data{sellprice_drag} =
291 qq|<td align=right><select name="sellprice_drag_$i">$prices</select></td>|;
296 $column_data{sellprice_drag} =
297 qq|<td align=right><input name="sellprice_$i" size=9 value=|
298 . $form->format_amount(\%myconfig, $form->{"prices_$i"},
303 $column_data{sellprice} =
304 qq|<td><input name="sellprice_$i" size=5 value=|
305 . $form->format_amount(\%myconfig, $form->{"sellprice_$i"},
309 $column_data{discount} =
310 qq|<td align=right><input name="discount_$i" size=3 value=|
311 . $form->format_amount(\%myconfig, $form->{"discount_$i"})
313 $column_data{linetotal} =
315 . $form->format_amount(\%myconfig, $linetotal, 2)
317 $column_data{bin} = qq|<td>$form->{"bin_$i"}</td>|;
319 ########################################
320 # Eintrag fuer Version 2.2.0 geaendert #
321 # neue Optik im Rechnungsformular #
322 ########################################
323 # if ($lizenzen && $form->{type} eq "invoice" && $form->{vc} eq "customer") {
324 # $column_data{license} = qq|<td><select name="licensenumber_$i">$form->{"lizenzen_$i"}></select></td>|;
327 # if ($form->{type} !~ /_quotation/) {
328 # $column_data{serialnr} = qq|<td><input name="serialnumber_$i" size=10 value="$form->{"serialnumber_$i"}"></td>|;
331 # $column_data{projectnr} = qq|<td><input name="projectnumber_$i" size=10 value="$form->{"projectnumber_$i"}"></td>|;
332 ############## ENDE Neueintrag ##################
337 map { print "\n$column_data{$_}" } @column_index;
342 <input type=hidden name="orderitems_id_$i" value=$form->{"orderitems_id_$i"}>
343 <input type=hidden name="bo_$i" value=$form->{"bo_$i"}>
345 <input type=hidden name="pricegroup_old_$i" value=$form->{"pricegroup_old_$i"}>
346 <input type=hidden name="price_old_$i" value=$form->{"price_old_$i"}>
347 <input type=hidden name="price_new_$i" value=|
348 . $form->format_amount(\%myconfig, $form->{"price_new_$i"}) . qq|>
350 <input type=hidden name="id_$i" value=$form->{"id_$i"}>
351 <input type=hidden name="inventory_accno_$i" value=$form->{"inventory_accno_$i"}>
352 <input type=hidden name="bin_$i" value="$form->{"bin_$i"}">
353 <input type=hidden name="partsgroup_$i" value="$form->{"partsgroup_$i"}">
354 <input type=hidden name="partnotes_$i" value="$form->{"partnotes_$i"}">
355 <input type=hidden name="income_accno_$i" value=$form->{"income_accno_$i"}>
356 <input type=hidden name="expense_accno_$i" value=$form->{"expense_accno_$i"}>
357 <input type=hidden name="listprice_$i" value="$form->{"listprice_$i"}">
358 <input type=hidden name="assembly_$i" value="$form->{"assembly_$i"}">
359 <input type=hidden name="taxaccounts_$i" value="$form->{"taxaccounts_$i"}">
360 <input type=hidden name="ordnumber_$i" value="$form->{"ordnumber_$i"}">
361 <input type=hidden name="transdate_$i" value="$form->{"transdate_$i"}">
362 <input type=hidden name="cusordnumber_$i" value="$form->{"cusordnumber_$i"}">
366 ########################################
367 # Eintrag fuer Version 2.2.0 geaendert #
368 # neue Optik im Rechnungsformular #
369 ########################################
373 <td colspan=$colspan>
375 if ($lizenzen && $form->{type} eq "invoice" && $form->{vc} eq "customer") {
376 my $selected = $form->{"licensenumber_$i"};
378 $form->{"lizenzen_$i"} =~ s/ selected//g;
379 $form->{"lizenzen_$i"} =~
380 s/value="${selected}"\>/value="${selected}" selected\>/;
381 $lizenzen_quoted = $form->{"lizenzen_$i"};
382 $lizenzen_quoted =~ s/\"/"/g;
384 <b>Lizenz\#</b> <select name="licensenumber_$i" size=1>
385 $form->{"lizenzen_$i"}
387 <input type=hidden name="lizenzen_$i" value="${lizenzen_quoted}">
390 if ($form->{type} !~ /_quotation/) {
392 <b>$serialnumber</b> <input name="serialnumber_$i" size=15 value="$form->{"serialnumber_$i"}">|;
396 <b>$projectnumber</b> <input name="projectnumber_$i" size=10 value="$form->{"projectnumber_$i"}">
397 <input type=hidden name="oldprojectnumber_$i" value="$form->{"oldprojectnumber_$i"}">
398 <input type=hidden name="project_id_$i" value="$form->{"project_id_$i"}">
404 ############## ENDE Neueintrag ##################
406 map { $form->{"${_}_base"} += $linetotal }
407 (split / /, $form->{"taxaccounts_$i"});
409 $form->{invsubtotal} += $linetotal;
418 $lxdebug->leave_sub();
421 ##################################################
422 # build html-code for pricegroups in variable $form->{prices_$j}
425 my $rowcount = shift;
426 $lxdebug->enter_sub();
427 for $j (1 .. $rowcount) {
429 my $pricegroup_old = $form->{"pricegroup_old_$i"};
430 if ($form->{PRICES}{$j}) {
434 foreach $item (@{ $form->{PRICES}{$j} }) {
435 $price = $form->round_amount($myconfig, $item->{price}, 5);
436 $price = $form->format_amount($myconfig, $item->{price}, 2);
437 $price = $item->{price};
438 $pricegroup_id = $item->{pricegroup_id};
439 $pricegroup = $item->{pricegroup};
441 # build dragdrop for pricegroups
443 qq|<option value="$price--$pricegroup_id"$item->{selected}>$pricegroup</option>\n|;
447 # set new selectedpricegroup_id and prices for "Preis"
448 if ($item->{selected}) {
449 $form->{"pricegroup_old_$j"} = $pricegroup_id;
450 $form->{"price_new_$j"} = $price;
451 $form->{"sellprice_$j"} = $price;
454 $form->{"prices_$j"} = $prices;
460 $lxdebug->leave_sub();
464 $lxdebug->enter_sub();
465 @column_index = qw(ndx partnumber description onhand sellprice);
467 $column_data{ndx} = qq|<th> </th>|;
468 $column_data{partnumber} =
469 qq|<th class=listheading>| . $locale->text('Number') . qq|</th>|;
470 $column_data{description} =
471 qq|<th class=listheading>| . $locale->text('Part Description') . qq|</th>|;
472 $column_data{sellprice} =
473 qq|<th class=listheading>| . $locale->text('Price') . qq|</th>|;
474 $column_data{onhand} =
475 qq|<th class=listheading>| . $locale->text('Qty') . qq|</th>|;
477 # list items with radio button on a form
480 $title = $locale->text('Select from one of the items below');
481 $colspan = $#column_index + 1;
486 <form method=post action=$form->{script}>
490 <th class=listtop colspan=$colspan>$title</th>
493 <tr class=listheading>|;
495 map { print "\n$column_data{$_}" } @column_index;
500 foreach $ref (@{ $form->{item_list} }) {
501 $checked = ($i++) ? "" : "checked";
504 if ($ref->{inventory_accno} > 0) {
505 $ref->{"lizenzen"} = qq|<option></option>|;
506 foreach $item (@{ $form->{LIZENZEN}{ $ref->{"id"} } }) {
507 $ref->{"lizenzen"} .=
508 qq|<option value=\"$item->{"id"}\">$item->{"licensenumber"}</option>|;
510 $ref->{"lizenzen"} .= qq|<option value=-1>Neue Lizenz</option>|;
511 $ref->{"lizenzen"} =~ s/\"/"/g;
515 map { $ref->{$_} =~ s/\"/"/g } qw(partnumber description unit);
519 $form->round_amount($ref->{sellprice} * (1 - $form->{tradediscount}), 2);
521 qq|<td><input name=ndx class=radio type=radio value=$i $checked></td>|;
522 $column_data{partnumber} =
523 qq|<td><input name="new_partnumber_$i" type=hidden value="$ref->{partnumber}">$ref->{partnumber}</td>|;
524 $column_data{description} =
525 qq|<td><input name="new_description_$i" type=hidden value="$ref->{description}">$ref->{description}</td>|;
526 $column_data{sellprice} =
527 qq|<td align=right><input name="new_sellprice_$i" type=hidden value=$ref->{sellprice}>|
528 . $form->format_amount(\%myconfig, $ref->{sellprice}, 2, " ")
530 $column_data{onhand} =
531 qq|<td align=right><input name="new_onhand_$i" type=hidden value=$ref->{onhand}>|
532 . $form->format_amount(\%myconfig, $ref->{onhand}, '', " ")
538 <tr class=listrow$j>|;
540 map { print "\n$column_data{$_}" } @column_index;
545 <input name="new_bin_$i" type=hidden value="$ref->{bin}">
546 <input name="new_listprice_$i" type=hidden value=$ref->{listprice}>
547 <input name="new_inventory_accno_$i" type=hidden value=$ref->{inventory_accno}>
548 <input name="new_income_accno_$i" type=hidden value=$ref->{income_accno}>
549 <input name="new_expense_accno_$i" type=hidden value=$ref->{expense_accno}>
550 <input name="new_unit_$i" type=hidden value="$ref->{unit}">
551 <input name="new_weight_$i" type=hidden value="$ref->{weight}">
552 <input name="new_assembly_$i" type=hidden value="$ref->{assembly}">
553 <input name="new_taxaccounts_$i" type=hidden value="$ref->{taxaccounts}">
554 <input name="new_partsgroup_$i" type=hidden value="$ref->{partsgroup}">
556 <input name="new_id_$i" type=hidden value=$ref->{id}>
561 <input name="new_lizenzen_$i" type=hidden value="$ref->{lizenzen}">
568 <tr><td colspan=8><hr size=3 noshade></td></tr>
571 <input name=lastndx type=hidden value=$i>
575 # delete action variable
576 map { delete $form->{$_} } qw(action item_list header);
578 # save all other form variables
579 foreach $key (keys %${form}) {
580 $form->{$key} =~ s/\"/"/g;
581 print qq|<input name=$key type=hidden value="$form->{$key}">\n|;
585 <input type=hidden name=nextsub value=item_selected>
588 <input class=submit type=submit name=action value="|
589 . $locale->text('Continue') . qq|">
596 $lxdebug->leave_sub();
600 $lxdebug->enter_sub();
602 # replace the last row with the checked row
603 $i = $form->{rowcount};
604 $i = $form->{assembly_rows} if ($form->{item} eq 'assembly');
610 #($form->{"sellprice_$i"},$form->{"$pricegroup_old_$i"}) = split /--/, $form->{"sellprice_$i"};
611 #$form->{"sellprice_$i"} = $form->{"sellprice_$i"};
613 # if there was a price entered, override it
614 $sellprice = $form->parse_amount(\%myconfig, $form->{"sellprice_$i"});
616 map { $form->{"${_}_$i"} = $form->{"new_${_}_$j"} }
617 qw(id partnumber description sellprice listprice inventory_accno income_accno expense_accno bin unit weight assembly taxaccounts partsgroup);
620 map { $form->{"${_}_$i"} = $form->{"new_${_}_$j"} } qw(lizenzen);
623 ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/);
625 $decimalplaces = ($dec > 2) ? $dec : 2;
628 $form->{"sellprice_$i"} = $sellprice;
631 # if there is an exchange rate adjust sellprice
632 if (($form->{exchangerate} * 1) != 0) {
633 $form->{"sellprice_$i"} /= $form->{exchangerate};
634 $form->{"sellprice_$i"} =
635 $form->round_amount($form->{"sellprice_$i"}, $decimalplaces);
639 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
640 qw(sellprice listprice weight);
642 $form->{sellprice} += ($form->{"sellprice_$i"} * $form->{"qty_$i"});
643 $form->{weight} += ($form->{"weight_$i"} * $form->{"qty_$i"});
646 $form->{"sellprice_$i"} * (1 - $form->{"discount_$i"} / 100) *
648 map { $form->{"${_}_base"} += $amount }
649 (split / /, $form->{"taxaccounts_$i"});
650 map { $amount += ($form->{"${_}_base"} * $form->{"${_}_rate"}) } split / /,
651 $form->{"taxaccounts_$i"}
652 if !$form->{taxincluded};
654 $form->{creditremaining} -= $amount;
656 $form->{"runningnumber_$i"} = $i;
658 # delete all the new_ variables
659 for $i (1 .. $form->{lastndx}) {
660 map { delete $form->{"new_${_}_$i"} }
661 qw(partnumber description sellprice bin listprice inventory_accno income_accno expense_accno unit assembly taxaccounts id);
664 map { delete $form->{$_} } qw(ndx lastndx nextsub);
669 $form->format_amount(\%myconfig, $form->{"${_}_$i"}, $decimalplaces)
670 } qw(sellprice listprice) if $form->{item} ne 'assembly';
672 # get pricegroups for parts
673 IS->get_pricegroups_for_parts(\%myconfig, \%$form);
675 # build up html code for prices_$i
676 set_pricegroup($form->{rowcount});
680 $lxdebug->leave_sub();
684 $lxdebug->enter_sub();
687 $form->{old_callback} = $form->escape($form->{callback}, 1);
688 $form->{callback} = $form->escape("$form->{script}?action=display_form", 1);
691 delete $form->{action};
693 # save all other form variables in a previousform variable
694 foreach $key (keys %$form) {
697 $form->{$key} =~ s/&/%26/g;
698 $previousform .= qq|$key=$form->{$key}&|;
701 $previousform = $form->escape($previousform, 1);
703 $i = $form->{rowcount};
704 map { $form->{"${_}_$i"} =~ s/\"/"/g } qw(partnumber description);
711 <h4 class=error>| . $locale->text('Item not on file!') . qq|
714 | . $locale->text('What type of item is this?') . qq|</h4>
716 <form method=post action=ic.pl>
720 <input class=radio type=radio name=item value=part checked> |
721 . $locale->text('Part') . qq|<br>
722 <input class=radio type=radio name=item value=service> |
723 . $locale->text('Service')
726 <input type=hidden name=previousform value="$previousform">
727 <input type=hidden name=partnumber value="$form->{"partnumber_$i"}">
728 <input type=hidden name=description value="$form->{"description_$i"}">
729 <input type=hidden name=rowcount value=$form->{rowcount}>
730 <input type=hidden name=taxaccount2 value=$form->{taxaccounts}>
731 <input type=hidden name=vc value=$form->{vc}>
733 <input type=hidden name=path value=$form->{path}>
734 <input type=hidden name=login value=$form->{login}>
735 <input type=hidden name=password value=$form->{password}>
737 <input type=hidden name=nextsub value=add>
740 <input class=submit type=submit name=action value="|
741 . $locale->text('Continue') . qq|">
748 $lxdebug->leave_sub();
752 $lxdebug->enter_sub();
754 # if we have a display_form
755 if ($form->{display_form}) {
756 &{"$form->{display_form}"};
759 if ( $form->{print_and_post}
760 && $form->{second_run}
761 && ($form->{action} eq "display_form")) {
762 for (keys %$form) { $old_form->{$_} = $form->{$_} }
763 $old_form->{rowcount}++;
765 #$form->{rowcount}--;
766 #$form->{rowcount}--;
768 $form->{print_and_post} = 0;
770 &print_form($old_form);
774 $form->{action} = "";
775 $form->{resubmit} = 0;
777 if ($form->{print_and_post} && !$form->{second_run}) {
778 $form->{second_run} = 1;
779 $form->{action} = "display_form";
781 my $rowcount = $form->{rowcount};
783 # get pricegroups for parts
784 IS->get_pricegroups_for_parts(\%myconfig, \%$form);
786 # build up html code for prices_$i
787 set_pricegroup($rowcount);
789 $form->{resubmit} = 1;
794 $numrows = ++$form->{rowcount};
795 $subroutine = "display_row";
797 if ($form->{item} eq 'part') {
799 #set preisgruppenanzahl
800 $numrows = $form->{price_rows};
801 $subroutine = "price_row";
803 &{$subroutine}($numrows);
805 $numrows = ++$form->{makemodel_rows};
806 $subroutine = "makemodel_row";
808 if ($form->{item} eq 'assembly') {
809 $numrows = ++$form->{price_rows};
810 $subroutine = "price_row";
812 &{$subroutine}($numrows);
814 $numrows = ++$form->{makemodel_rows};
815 $subroutine = "makemodel_row";
817 # create makemodel rows
818 &{$subroutine}($numrows);
820 $numrows = ++$form->{assembly_rows};
821 $subroutine = "assembly_row";
823 if ($form->{item} eq 'service') {
824 $numrows = ++$form->{price_rows};
825 $subroutine = "price_row";
827 &{$subroutine}($numrows);
833 &{$subroutine}($numrows) if $numrows;
837 $lxdebug->leave_sub();
841 $lxdebug->enter_sub();
845 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)
848 # remove any makes or model rows
849 if ($form->{item} eq 'part') {
850 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
851 qw(listprice sellprice lastcost weight rop);
853 @flds = (make, model);
854 for my $i (1 .. ($form->{makemodel_rows})) {
855 if (($form->{"make_$i"} ne "") || ($form->{"model_$i"} ne "")) {
859 map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
864 $form->redo_rows(\@flds, \@a, $count, $form->{makemodel_rows});
865 $form->{makemodel_rows} = $count;
867 } elsif ($form->{item} eq 'assembly') {
869 $form->{sellprice} = 0;
871 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
872 qw(listprice rop stock);
875 qw(id qty unit bom partnumber description sellprice weight runningnumber partsgroup);
877 for my $i (1 .. ($form->{assembly_rows} - 1)) {
878 if ($form->{"qty_$i"}) {
882 $form->{"qty_$i"} = $form->parse_amount(\%myconfig, $form->{"qty_$i"});
884 map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
886 #($form->{"sellprice_$i"},$form->{"$pricegroup_old_$i"}) = split /--/, $form->{"sellprice_$i"};
888 $form->{sellprice} += ($form->{"qty_$i"} * $form->{"sellprice_$i"});
889 $form->{weight} += ($form->{"qty_$i"} * $form->{"weight_$i"});
894 $form->{sellprice} = $form->round_amount($form->{sellprice}, 2);
896 $form->redo_rows(\@flds, \@a, $count, $form->{assembly_rows});
897 $form->{assembly_rows} = $count;
900 @flds = qw(make model);
903 for my $i (1 .. ($form->{makemodel_rows})) {
904 if (($form->{"make_$i"} ne "") || ($form->{"model_$i"} ne "")) {
908 map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
913 $form->redo_rows(\@flds, \@a, $count, $form->{makemodel_rows});
914 $form->{makemodel_rows} = $count;
918 # this section applies to invoices and orders
919 # remove any empty numbers
920 if ($form->{rowcount}) {
921 for my $i (1 .. $form->{rowcount} - 1) {
922 if ($form->{"partnumber_$i"}) {
926 map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
929 if ($form->{"licensenumber_$i"} == -1) {
937 $form->redo_rows(\@flds, \@a, $count, $form->{rowcount});
938 $form->{rowcount} = $count;
940 $form->{creditremaining} -= &invoicetotal;
947 if ( $form->{type} =~ (/sales_quotation/)
948 or (($form->{level} =~ /Sales/) and ($form->{type} =~ /invoice/))
949 or (($form->{level} eq undef) and ($form->{type} =~ /invoice/))
950 or ($form->{type} =~ /sales_order/)) {
952 # get pricegroups for parts
953 IS->get_pricegroups_for_parts(\%myconfig, \%$form);
955 # build up html code for prices_$i
956 set_pricegroup($form->{rowcount});
962 $lxdebug->leave_sub();
966 $lxdebug->enter_sub();
968 $form->{oldinvtotal} = 0;
970 # add all parts and deduct paid
971 map { $form->{"${_}_base"} = 0 } split / /, $form->{taxaccounts};
973 my ($amount, $sellprice, $discount, $qty);
975 for my $i (1 .. $form->{rowcount}) {
976 $sellprice = $form->parse_amount(\%myconfig, $form->{"sellprice_$i"});
977 $discount = $form->parse_amount(\%myconfig, $form->{"discount_$i"});
978 $qty = $form->parse_amount(\%myconfig, $form->{"qty_$i"});
980 #($form->{"sellprice_$i"}, $form->{"$pricegroup_old_$i"}) = split /--/, $form->{"sellprice_$i"};
982 $amount = $sellprice * (1 - $discount / 100) * $qty;
983 map { $form->{"${_}_base"} += $amount }
984 (split / /, $form->{"taxaccounts_$i"});
985 $form->{oldinvtotal} += $amount;
988 map { $form->{oldinvtotal} += ($form->{"${_}_base"} * $form->{"${_}_rate"}) }
989 split / /, $form->{taxaccounts}
990 if !$form->{taxincluded};
992 $form->{oldtotalpaid} = 0;
993 for $i (1 .. $form->{paidaccounts}) {
994 $form->{oldtotalpaid} += $form->{"paid_$i"};
997 $lxdebug->leave_sub();
1000 return ($form->{oldinvtotal} - $form->{oldtotalpaid});
1003 sub validate_items {
1004 $lxdebug->enter_sub();
1006 # check if items are valid
1007 if ($form->{rowcount} == 1) {
1012 for $i (1 .. $form->{rowcount} - 1) {
1013 $form->isblank("partnumber_$i",
1014 $locale->text('Number missing in Row') . " $i");
1017 $lxdebug->leave_sub();
1021 $lxdebug->enter_sub();
1022 if ($form->{second_run}) {
1023 $form->{print_and_post} = 0;
1025 $form->{ordnumber} = $form->{invnumber};
1027 map { delete $form->{$_} } qw(id printed emailed queued);
1028 if ($form->{script} eq 'ir.pl' || $form->{type} eq 'request_quotation') {
1029 $form->{title} = $locale->text('Add Purchase Order');
1030 $form->{vc} = 'vendor';
1031 $form->{type} = 'purchase_order';
1034 if ($form->{script} eq 'is.pl' || $form->{type} eq 'sales_quotation') {
1035 $form->{title} = $locale->text('Add Sales Order');
1036 $form->{vc} = 'customer';
1037 $form->{type} = 'sales_order';
1040 $form->{script} = 'oe.pl';
1042 $form->{shipto} = 1;
1044 $form->{rowcount}--;
1046 ($null, $form->{cp_id}) = split /--/, $form->{contact};
1047 $form->{cp_id} *= 1;
1049 require "$form->{path}/$form->{script}";
1051 map { $form->{"select$_"} = "" } ($form->{vc}, currency);
1053 $currency = $form->{currency};
1057 $form->{currency} = $currency;
1058 $form->{exchangerate} = "";
1059 $form->{forex} = "";
1060 $form->{exchangerate} = $exchangerate
1064 $form->check_exchangerate(
1065 \%myconfig, $form->{currency}, $form->{transdate}, $buysell
1071 $lxdebug->leave_sub();
1075 $lxdebug->enter_sub();
1076 if ($form->{second_run}) {
1077 $form->{print_and_post} = 0;
1079 map { delete $form->{$_} } qw(id printed emailed queued);
1081 if ($form->{script} eq 'ir.pl' || $form->{type} eq 'purchase_order') {
1082 $form->{title} = $locale->text('Add Request for Quotation');
1083 $form->{vc} = 'vendor';
1084 $form->{type} = 'request_quotation';
1087 if ($form->{script} eq 'is.pl' || $form->{type} eq 'sales_order') {
1088 $form->{title} = $locale->text('Add Quotation');
1089 $form->{vc} = 'customer';
1090 $form->{type} = 'sales_quotation';
1094 ($null, $form->{cp_id}) = split /--/, $form->{contact};
1095 $form->{cp_id} *= 1;
1097 $form->{script} = 'oe.pl';
1099 $form->{shipto} = 1;
1101 $form->{rowcount}--;
1103 require "$form->{path}/$form->{script}";
1105 map { $form->{"select$_"} = "" } ($form->{vc}, currency);
1107 $currency = $form->{currency};
1111 $form->{currency} = $currency;
1112 $form->{exchangerate} = "";
1113 $form->{forex} = "";
1114 $form->{exchangerate} = $exchangerate
1118 $form->check_exchangerate(
1119 \%myconfig, $form->{currency}, $form->{transdate}, $buysell
1125 $lxdebug->leave_sub();
1129 $lxdebug->enter_sub();
1130 if ($form->{second_run}) {
1131 $form->{print_and_post} = 0;
1132 $form->{resubmit} = 0;
1134 if ($myconfig{role} eq 'admin') {
1136 <th align=right nowrap=true>| . $locale->text('Bcc') . qq|</th>
1137 <td><input name=bcc size=30 value="$form->{bcc}"></td>
1141 if ($form->{formname} =~ /(pick|packing|bin)_list/) {
1142 $form->{email} = $form->{shiptoemail} if $form->{shiptoemail};
1145 $name = $form->{ $form->{vc} };
1147 $title = $locale->text('E-mail') . " $name";
1149 $form->{oldmedia} = $form->{media};
1150 $form->{media} = "email";
1157 <form method=post action=$form->{script}>
1161 <th class=listtop>$title</th>
1163 <tr height="5"></tr>
1168 <th align=right nowrap>| . $locale->text('To') . qq|</th>
1169 <td><input name=email size=30 value="$form->{email}"></td>
1170 <th align=right nowrap>| . $locale->text('Cc') . qq|</th>
1171 <td><input name=cc size=30 value="$form->{cc}"></td>
1174 <th align=right nowrap>| . $locale->text('Subject') . qq|</th>
1175 <td><input name=subject size=30 value="$form->{subject}"></td>
1185 <th align=left nowrap>| . $locale->text('Message') . qq|</th>
1188 <td><textarea name=message rows=15 cols=60 wrap=soft>$form->{message}</textarea></td>
1199 map { delete $form->{$_} }
1200 qw(action email cc bcc subject message formname sendmode format header override);
1202 # save all other variables
1203 foreach $key (keys %$form) {
1204 $form->{$key} =~ s/\"/"/g;
1205 print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
1212 <td><hr size=3 noshade></td>
1216 <input type=hidden name=nextsub value=send_email>
1219 <input name=action class=submit type=submit value="|
1220 . $locale->text('Continue') . qq|">
1227 $lxdebug->leave_sub();
1231 $lxdebug->enter_sub();
1233 $old_form = new Form;
1235 map { $old_form->{$_} = $form->{$_} } keys %$form;
1236 $old_form->{media} = $form->{oldmedia};
1238 &print_form($old_form);
1240 $lxdebug->leave_sub();
1244 $lxdebug->enter_sub();
1245 $form->{sendmode} = "attachment";
1246 $form->{copies} = 3 unless $form->{copies};
1248 $form->{PD}{ $form->{formname} } = "selected";
1249 $form->{DF}{ $form->{format} } = "";
1250 $form->{OP}{ $form->{media} } = "selected";
1251 $form->{SM}{ $form->{sendmode} } = "selected";
1253 if ($form->{type} eq 'purchase_order') {
1254 $type = qq|<select name=formname>
1255 <option value=purchase_order $form->{PD}{purchase_order}>|
1256 . $locale->text('Purchase Order') . qq|
1257 <option value=bin_list $form->{PD}{bin_list}>|
1258 . $locale->text('Bin List');
1261 if ($form->{type} eq 'sales_order') {
1262 $type = qq|<select name=formname>
1263 <option value=sales_order $form->{PD}{sales_order}>|
1264 . $locale->text('Confirmation') . qq|
1265 <option value=pick_list $form->{PD}{pick_list}>|
1266 . $locale->text('Pick List') . qq|
1267 <option value=packing_list $form->{PD}{packing_list}>|
1268 . $locale->text('Packing List');
1271 if ($form->{type} =~ /_quotation$/) {
1272 $type = qq|<select name=formname>
1273 <option value="$`_quotation" $form->{PD}{"$`_quotation"}>|
1274 . $locale->text('Quotation') . qq|
1278 if ($form->{type} eq 'invoice') {
1279 $type = qq|<select name=formname>
1280 <option value=invoice $form->{PD}{invoice}>| . $locale->text('Invoice');
1283 if ($form->{type} eq 'ship_order') {
1284 $type = qq|<select name=formname>
1285 <option value=pick_list $form->{PD}{pick_list}>|
1286 . $locale->text('Pick List') . qq|
1287 <option value=packing_list $form->{PD}{packing_list}>|
1288 . $locale->text('Packing List');
1291 if ($form->{type} eq 'receive_order') {
1292 $type = qq|<select name=formname>
1293 <option value=bin_list $form->{PD}{bin_list}>|
1294 . $locale->text('Bin List');
1297 if ($form->{media} eq 'email') {
1298 $media = qq|<select name=sendmode>
1299 <option value=attachment $form->{SM}{attachment}>|
1300 . $locale->text('Attachment') . qq|
1301 <option value=inline $form->{SM}{inline}>| . $locale->text('In-line');
1303 $media = qq|<select name=media>
1304 <option value=screen $form->{OP}{screen}>| . $locale->text('Screen');
1305 if ($myconfig{printer} && $latex) {
1307 <option value=printer $form->{OP}{printer}>|
1308 . $locale->text('Printer');
1312 <option value=queue $form->{OP}{queue}>| . $locale->text('Queue');
1316 $format = qq|<select name=format>
1317 <option value=html $form->{DF}{html}>html|;
1320 $format = qq|<select name=format>
1321 <option value=pdf $form->{DF}{pdf}>| . $locale->text('PDF') . qq|
1322 <option value=html $form->{DF}{html}>html
1323 <option value=postscript $form->{DF}{postscript}>|
1324 . $locale->text('Postscript');
1327 $language = qq|<select name=language>
1328 <option value=""></option>|;
1329 %lang = (de => "deutsch", en => "englisch", fr => "französisch");
1330 foreach $item (keys %lang) {
1331 if ($form->{language} eq $item) {
1332 $language .= qq|<option value="$item" selected>$lang{$item}</option>|;
1334 $language .= qq|<option value="$item">$lang{$item}</option>|;
1339 <table width=100% cellspacing=0 cellpadding=0>
1344 <td>$type</select></td>
1345 <td>$language</select</td>
1346 <td>$format</select></td>
1347 <td>$media</select></td>
1350 if ($myconfig{printer} && $latex && $form->{media} ne 'email') {
1352 <td>| . $locale->text('Copies') . qq|
1353 <input name=copies size=2 value=$form->{copies}></td>
1357 $form->{groupitems} = "checked" if $form->{groupitems};
1360 <td>| . $locale->text('Group Items') . qq|</td>
1361 <td><input name=groupitems type=checkbox class=checkbox $form->{groupitems}></td>
1370 if ($form->{printed} =~ /$form->{formname}/) {
1372 <th>\|| . $locale->text('Printed') . qq|\|</th>
1376 if ($form->{emailed} =~ /$form->{formname}/) {
1378 <th>\|| . $locale->text('E-mailed') . qq|\|</th>
1382 if ($form->{queued} =~ /$form->{formname}/) {
1384 <th>\|| . $locale->text('Queued') . qq|\|</th>
1396 $lxdebug->leave_sub();
1400 $lxdebug->enter_sub();
1401 if ($form->{second_run}) {
1402 $form->{print_and_post} = 0;
1405 # if this goes to the printer pass through
1406 if ($form->{media} eq 'printer' || $form->{media} eq 'queue') {
1407 $form->error($locale->text('Select postscript or PDF!'))
1408 if ($form->{format} !~ /(postscript|pdf)/);
1410 $old_form = new Form;
1411 map { $old_form->{$_} = $form->{$_} } keys %$form;
1414 &print_form($old_form);
1416 $lxdebug->leave_sub();
1420 $lxdebug->enter_sub();
1421 my ($old_form) = @_;
1425 $numberfld = "invnumber";
1428 ($form->{display_form}) ? $form->{display_form} : "display_form";
1430 # $form->{"notes"} will be overridden by the customer's/vendor's "notes" field. So save it here.
1431 $form->{ $form->{"formname"} . "notes" } = $form->{"notes"};
1433 if ($form->{formname} eq "invoice") {
1434 $form->{label} = $locale->text('Invoice');
1436 if ($form->{formname} eq "packing_list") {
1438 # this is from an invoice
1439 $form->{label} = $locale->text('Packing List');
1441 if ($form->{formname} eq 'sales_order') {
1444 $form->{"${inv}date"} = $form->{transdate};
1445 $form->{label} = $locale->text('Sales Order');
1446 $numberfld = "sonumber";
1449 if ($form->{formname} eq 'packing_list' && $form->{type} ne 'invoice') {
1451 # we use the same packing list as from an invoice
1454 $form->{invdate} = $form->{"${inv}date"} = $form->{transdate};
1455 $form->{label} = $locale->text('Packing List');
1458 if ($form->{formname} eq 'pick_list') {
1461 $form->{"${inv}date"} =
1462 ($form->{transdate}) ? $form->{transdate} : $form->{invdate};
1463 $form->{label} = $locale->text('Pick List');
1464 $order = 1 unless $form->{type} eq 'invoice';
1466 if ($form->{formname} eq 'purchase_order') {
1469 $form->{"${inv}date"} = $form->{transdate};
1470 $form->{label} = $locale->text('Purchase Order');
1471 $numberfld = "ponumber";
1474 if ($form->{formname} eq 'bin_list') {
1477 $form->{"${inv}date"} = $form->{transdate};
1478 $form->{label} = $locale->text('Bin List');
1481 if ($form->{formname} eq 'sales_quotation') {
1484 $form->{"${inv}date"} = $form->{transdate};
1485 $form->{label} = $locale->text('Quotation');
1486 $numberfld = "sqnumber";
1489 if ($form->{formname} eq 'request_quotation') {
1492 $form->{"${inv}date"} = $form->{transdate};
1493 $form->{label} = $locale->text('Quotation');
1494 $numberfld = "rfqnumber";
1498 $form->isblank("email", $locale->text('E-mail address missing!'))
1499 if ($form->{media} eq 'email');
1500 $form->isblank("${inv}date",
1501 $locale->text($form->{label} . ' Date missing!'));
1503 # $locale->text('Invoice Number missing!')
1504 # $locale->text('Invoice Date missing!')
1505 # $locale->text('Packing List Number missing!')
1506 # $locale->text('Packing List Date missing!')
1507 # $locale->text('Order Number missing!')
1508 # $locale->text('Order Date missing!')
1509 # $locale->text('Quotation Number missing!')
1510 # $locale->text('Quotation Date missing!')
1513 if (!$form->{"${inv}number"} && !$form->{preview}) {
1514 $form->{"${inv}number"} = $form->update_defaults(\%myconfig, $numberfld);
1515 if ($form->{media} ne 'email') {
1517 # get pricegroups for parts
1518 IS->get_pricegroups_for_parts(\%myconfig, \%$form);
1520 # build up html code for prices_$i
1521 set_pricegroup($form->{rowcount});
1523 $form->{rowcount}--;
1532 # Save the email address given in the form because it should override the setting saved for the customer/vendor.
1533 my ($saved_email, $saved_cc, $saved_bcc) =
1534 ($form->{"email"}, $form->{"cc"}, $form->{"bcc"});
1536 $language = $form->{language};
1537 &{"$form->{vc}_details"};
1538 $form->{language} = $language;
1540 $form->{"email"} = $saved_email if ($saved_email);
1541 $form->{"cc"} = $saved_cc if ($saved_cc);
1542 $form->{"bcc"} = $saved_bcc if ($saved_bcc);
1545 foreach $i (1 .. $form->{rowcount}) {
1547 ("partnumber_$i", "description_$i",
1548 "partsgroup_$i", "serialnumber_$i",
1549 "bin_$i", "unit_$i");
1551 map { push @a, "${_}_description" } split / /, $form->{taxaccounts};
1553 $ARAP = ($form->{vc} eq 'customer') ? "AR" : "AP";
1556 # format payment dates
1557 for $i (1 .. $form->{paidaccounts} - 1) {
1558 $form->{"datepaid_$i"} = $locale->date(\%myconfig, $form->{"datepaid_$i"});
1559 push @a, "${ARAP}_paid_$i", "source_$i", "memo_$i";
1562 $form->format_string(@a);
1564 ($form->{employee}) = split /--/, $form->{employee};
1565 ($form->{warehouse}, $form->{warehouse_id}) = split /--/, $form->{warehouse};
1567 # create the form variables
1569 OE->order_details(\%myconfig, \%$form);
1571 IS->invoice_details(\%myconfig, \%$form, $locale);
1574 map { $form->{$_} = $locale->date(\%myconfig, $form->{$_}, 1) }
1575 ("${inv}date", "${due}date", "shippingdate");
1577 @a = qw(name street zipcode city country);
1581 # if there is no shipto fill it in from billto
1582 foreach $item (@a) {
1583 if ($form->{"shipto$item"}) {
1590 if ( $form->{formname} eq 'purchase_order'
1591 || $form->{formname} eq 'request_quotation') {
1592 $form->{shiptoname} = $myconfig{company};
1593 $form->{shiptostreet} = $myconfig{address};
1595 map { $form->{"shipto$_"} = $form->{$_} } @a;
1599 $form->{notes} =~ s/^\s+//g;
1601 # some of the stuff could have umlauts so we translate them
1603 qw(shiptoname shiptostreet shiptozipcode shiptocity shiptocountry shiptoemail shippingpoint shipvia company address signature employee contact);
1605 push @a, ("${inv}date", "${due}date", email, cc, bcc);
1607 $form->format_string(@a);
1609 $form->{templates} = "$myconfig{templates}";
1610 if ($form->{language} ne "") {
1611 $form->{language} = "_" . $form->{language};
1614 $form->{IN} = "$form->{formname}$form->{language}.html";
1615 if ($form->{format} eq 'postscript') {
1616 $form->{postscript} = 1;
1617 $form->{IN} =~ s/html$/tex/;
1619 if ($form->{format} eq 'pdf') {
1621 $form->{IN} =~ s/html$/tex/;
1624 if ($form->{media} eq 'printer') {
1625 $form->{OUT} = "| $myconfig{printer}";
1626 $form->{printed} .= " $form->{formname}";
1627 $form->{printed} =~ s/^ //;
1629 $printed = $form->{printed};
1631 if ($form->{media} eq 'email') {
1632 $form->{subject} = qq|$form->{label} $form->{"${inv}number"}|
1633 unless $form->{subject};
1635 $form->{OUT} = "$sendmail";
1637 $form->{emailed} .= " $form->{formname}";
1638 $form->{emailed} =~ s/^ //;
1640 $emailed = $form->{emailed};
1642 if ($form->{media} eq 'queue') {
1643 %queued = split / /, $form->{queued};
1645 if ($filename = $queued{ $form->{formname} }) {
1646 $form->{queued} =~ s/$form->{formname} $filename//;
1647 unlink "$spool/$filename";
1648 $filename =~ s/\..*$//g;
1654 $filename .= ($form->{postscript}) ? '.ps' : '.pdf';
1655 $form->{OUT} = ">$spool/$filename";
1658 $form->{queued} .= " $form->{formname} $filename";
1660 $form->{queued} =~ s/^ //;
1662 $queued = $form->{queued};
1664 $form->parse_template(\%myconfig, $userspath);
1666 $form->{callback} = "";
1668 if ($form->{media} eq 'email') {
1669 $form->{message} = $locale->text('sent') unless $form->{message};
1671 $message = $form->{message};
1673 # if we got back here restore the previous form
1674 if ($form->{media} =~ /(printer|email|queue)/) {
1676 $form->update_status(\%myconfig)
1677 if ($form->{media} eq 'queue' && $form->{id});
1681 $old_form->{"${inv}number"} = $form->{"${inv}number"};
1683 # restore and display form
1684 map { $form->{$_} = $old_form->{$_} } keys %$old_form;
1686 $form->{queued} = $queued;
1687 $form->{printed} = $printed;
1688 $form->{emailed} = $emailed;
1689 $form->{message} = $message;
1691 $form->{rowcount}--;
1692 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
1693 qw(exchangerate creditlimit creditremaining);
1695 for $i (1 .. $form->{paidaccounts}) {
1697 $form->{"${_}_$i"} =
1698 $form->parse_amount(\%myconfig, $form->{"${_}_$i"})
1699 } qw(paid exchangerate);
1707 ($form->{media} eq 'printer')
1708 ? $locale->text('sent to printer')
1709 : $locale->text('emailed to') . " $form->{email}";
1710 $form->redirect(qq|$form->{label} $form->{"${inv}number"} $msg|);
1715 $lxdebug->leave_sub();
1718 sub customer_details {
1719 $lxdebug->enter_sub();
1720 IS->customer_details(\%myconfig, \%$form);
1721 $lxdebug->leave_sub();
1724 sub vendor_details {
1725 $lxdebug->enter_sub();
1727 IR->vendor_details(\%myconfig, \%$form);
1729 $lxdebug->leave_sub();
1733 $lxdebug->enter_sub();
1735 $form->{postasnew} = 1;
1736 map { delete $form->{$_} } qw(printed emailed queued);
1740 $lxdebug->leave_sub();
1744 $lxdebug->enter_sub();
1745 if ($form->{second_run}) {
1746 $form->{print_and_post} = 0;
1749 $title = $form->{title};
1750 $form->{title} = $locale->text('Ship to');
1752 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
1753 qw(exchangerate creditlimit creditremaining);
1755 # get details for name
1756 &{"$form->{vc}_details"};
1759 ($form->{vc} eq 'customer')
1760 ? $locale->text('Customer Number')
1761 : $locale->text('Vendor Number');
1763 # get pricegroups for parts
1764 IS->get_pricegroups_for_parts(\%myconfig, \%$form);
1766 # build up html code for prices_$i
1767 set_pricegroup($form->{rowcount});
1769 $nextsub = ($form->{display_form}) ? $form->{display_form} : "display_form";
1771 $form->{rowcount}--;
1778 <form method=post action=$form->{script}>
1784 <tr class=listheading>
1785 <th class=listheading colspan=2 width=50%>|
1786 . $locale->text('Billing Address') . qq|</th>
1787 <th class=listheading width=50%>|
1788 . $locale->text('Shipping Address') . qq|</th>
1790 <tr height="5"></tr>
1792 <th align=right nowrap>$number</th>
1793 <td>$form->{"$form->{vc}number"}</td>
1796 <th align=right nowrap>| . $locale->text('Company Name') . qq|</th>
1797 <td>$form->{name}</td>
1798 <td><input name=shiptoname size=35 value="$form->{shiptoname}"></td>
1801 <th align=right nowrap>| . $locale->text('Street') . qq|</th>
1802 <td>$form->{street}</td>
1803 <td><input name=shiptostreet size=35 value="$form->{shiptostreet}"></td>
1806 <th align=right nowrap>| . $locale->text('Zipcode') . qq|</th>
1807 <td>$form->{zipcode}</td>
1808 <td><input name=shiptozipcode size=35 value="$form->{shiptozipcode}"></td>
1811 <th align=right nowrap>| . $locale->text('City') . qq|</th>
1812 <td>$form->{city}</td>
1813 <td><input name=shiptocity size=35 value="$form->{shiptocity}"></td>
1816 <th align=right nowrap>| . $locale->text('Country') . qq|</th>
1817 <td>$form->{country}</td>
1818 <td><input name=shiptocountry size=35 value="$form->{shiptocountry}"></td>
1821 <th align=right nowrap>| . $locale->text('Contact') . qq|</th>
1822 <td>$form->{contact}</td>
1823 <td><input name=shiptocontact size=35 value="$form->{shiptocontact}"></td>
1826 <th align=right nowrap>| . $locale->text('Phone') . qq|</th>
1827 <td>$form->{"$form->{vc}phone"}</td>
1828 <td><input name=shiptophone size=20 value="$form->{shiptophone}"></td>
1831 <th align=right nowrap>| . $locale->text('Fax') . qq|</th>
1832 <td>$form->{"$form->{vc}fax"}</td>
1833 <td><input name=shiptofax size=20 value="$form->{shiptofax}"></td>
1836 <th align=right nowrap>| . $locale->text('E-mail') . qq|</th>
1837 <td>$form->{email}</td>
1838 <td><input name=shiptoemail size=35 value="$form->{shiptoemail}"></td>
1845 <input type=hidden name=nextsub value=$nextsub>
1849 map { delete $form->{$_} }
1850 qw(shiptoname shiptostreet shiptozipcode shiptocity shiptocountry shiptocontact shiptophone shiptofax shiptoemail header);
1851 $form->{title} = $title;
1853 foreach $key (keys %$form) {
1854 $form->{$key} =~ s/\"/"/g;
1855 print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
1863 <input class=submit type=submit name=action value="|
1864 . $locale->text('Continue') . qq|">
1871 $lxdebug->leave_sub();
1875 $lxdebug->enter_sub();
1880 $form->{old_callback} = $form->escape($form->{callback}, 1);
1881 $form->{callback} = $form->escape("$form->{script}?action=display_form", 1);
1882 $form->{old_callback} = $form->escape($form->{old_callback}, 1);
1885 delete $form->{action};
1886 $customer = $form->{customer};
1887 map { $form->{"old_$_"} = $form->{"${_}_$row"} } qw(partnumber description);
1889 # save all other form variables in a previousform variable
1890 $form->{row} = $row;
1891 foreach $key (keys %$form) {
1894 $form->{$key} =~ s/&/%26/g;
1895 $previousform .= qq|$key=$form->{$key}&|;
1898 $previousform = $form->escape($previousform, 1);
1900 $form->{script} = "licenses.pl";
1902 map { $form->{$_} = $form->{"old_$_"} } qw(partnumber description);
1903 map { $form->{$_} = $form->escape($form->{$_}, 1) }
1904 qw(partnumber description);
1906 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|;
1909 $lxdebug->leave_sub();