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')
79 ########################################
80 # Eintrag fuer Version 2.2.0 geaendert #
81 # neue Optik im Rechnungsformular #
82 ########################################
84 $lxdebug->enter_sub();
86 if ($lizenzen && $form->{vc} eq "customer") {
87 if ($form->{type} =~ /sales_order/) {
88 @column_index = (runningnumber, partnumber, description, ship, qty);
89 } elsif ($form->{type} =~ /sales_quotation/) {
90 @column_index = (runningnumber, partnumber, description, qty);
92 @column_index = (runningnumber, partnumber, description, qty);
95 if ( ($form->{type} =~ /purchase_order/)
96 || ($form->{type} =~ /sales_order/)) {
97 @column_index = (runningnumber, partnumber, description, ship, qty);
99 @column_index = (runningnumber, partnumber, description, qty);
102 ############## ENDE Neueintrag ##################
104 my $dimension_units = AM->retrieve_units(\%myconfig, $form, "dimension");
105 my $service_units = AM->retrieve_units(\%myconfig, $form, "service");
106 my $all_units = AM->retrieve_units(\%myconfig, $form);
108 push @column_index, qw(unit);
110 #for pricegroups column
111 if ( $form->{type} =~ (/sales_quotation/)
112 or (($form->{level} =~ /Sales/) and ($form->{type} =~ /invoice/))
113 or (($form->{level} eq undef) and ($form->{type} =~ /invoice/))
114 or ($form->{type} =~ /sales_order/)) {
115 push @column_index, qw(sellprice_pg);
118 push @column_index, qw(sellprice);
120 if ($form->{vc} eq 'customer') {
121 push @column_index, qw(discount);
124 push @column_index, "linetotal";
126 my $colspan = $#column_index + 1;
128 $form->{invsubtotal} = 0;
129 map { $form->{"${_}_base"} = 0 } (split / /, $form->{taxaccounts});
131 ########################################
132 # Eintrag fuer Version 2.2.0 geaendert #
133 # neue Optik im Rechnungsformular #
134 ########################################
135 $column_data{runningnumber} =
136 qq|<th align=left nowrap width=5 class=listheading>|
137 . $locale->text('No.')
139 $column_data{partnumber} =
140 qq|<th align=left nowrap width=12 class=listheading>|
141 . $locale->text('Number')
143 $column_data{description} =
144 qq|<th align=left nowrap width=30 class=listheading>|
145 . $locale->text('Part Description')
148 qq|<th align=left nowrap width=5 class=listheading>|
149 . $locale->text('Ship')
152 qq|<th align=left nowrap width=5 class=listheading>|
153 . $locale->text('Qty')
156 qq|<th align=left nowrap width=5 class=listheading>|
157 . $locale->text('Unit')
159 $column_data{license} =
160 qq|<th align=left nowrap width=10 class=listheading>|
161 . $locale->text('License')
163 $column_data{serialnr} =
164 qq|<th align=left nowrap width=10 class=listheading>|
165 . $locale->text('Serial No.')
167 $column_data{projectnr} =
168 qq|<th align=left nowrap width=10 class=listheading>|
169 . $locale->text('Project')
171 $column_data{sellprice} =
172 qq|<th align=left nowrap width=15 class=listheading>|
173 . $locale->text('Price')
175 $column_data{sellprice_pg} =
176 qq|<th align=left nowrap width=15 class=listheading>|
177 . $locale->text('Pricegroup')
179 $column_data{discount} =
180 qq|<th align=left class=listheading>|
181 . $locale->text('Discount')
183 $column_data{linetotal} =
184 qq|<th align=left nowrap width=10 class=listheading>|
185 . $locale->text('Extended')
188 qq|<th align=left nowrap width=10 class=listheading>|
189 . $locale->text('Bin')
191 ############## ENDE Neueintrag ##################
197 <tr class=listheading>|;
199 map { print "\n$column_data{$_}" } @column_index;
205 $runningnumber = $locale->text('No.');
206 $deliverydate = $locale->text('Delivery Date');
207 $serialnumber = $locale->text('Serial No.');
208 $projectnumber = $locale->text('Project');
209 $partsgroup = $locale->text('Group');
210 $reqdate = $locale->text('Reqdate');
212 $delvar = 'deliverydate';
214 if ($form->{type} =~ /_order$/ || $form->{type} =~ /_quotation$/) {
215 $deliverydate = $locale->text('Required by');
219 for $i (1 .. $numrows) {
224 $form->parse_amount(\%myconfig, $form->{"${_}_$i"})
225 } qw(qty ship discount sellprice price_new price_old) unless ($form->{simple_save});
227 if (!$form->{"unit_old_$i"}) {
228 # Neue Ware aus der Datenbank. In diesem Fall ist unit_$i die
229 # Einheit, wie sie in den Stammdaten hinterlegt wurde.
230 # Es sollte also angenommen werden, dass diese ausgewaehlt war.
231 $form->{"unit_old_$i"} = $form->{"unit_$i"};
236 # Die zuletzt ausgewaehlte mit der aktuell ausgewaehlten Einheit
237 # vergleichen und bei Unterschied den Preis entsprechend umrechnen.
238 $form->{"selected_unit_$i"} = $form->{"unit_$i"} unless ($form->{"selected_unit_$i"});
240 my $check_units = $form->{"inventory_accno_$i"} ? $dimension_units : $service_units;
241 if (!$check_units->{$form->{"selected_unit_$i"}} ||
242 ($check_units->{$form->{"selected_unit_$i"}}->{"base_unit"} ne
243 $all_units->{$form->{"unit_old_$i"}}->{"base_unit"})) {
244 # Die ausgewaehlte Einheit ist fuer diesen Artikel nicht gueltig
245 # (z.B. Dimensionseinheit war ausgewaehlt, es handelt sich aber
246 # um eine Dienstleistung). Dann keinerlei Umrechnung vornehmen.
247 $form->{"unit_old_$i"} = $form->{"selected_unit_$i"} = $form->{"unit_$i"};
249 if ((!$form->{"prices_$i"}) || ($form->{"new_pricegroup_$i"} == $form->{"old_pricegroup_$i"})) {
250 if ($form->{"unit_old_$i"} ne $form->{"selected_unit_$i"}) {
252 if (defined($all_units->{$form->{"unit_old_$i"}}->{"factor"}) &&
253 $all_units->{$form->{"unit_old_$i"}}->{"factor"}) {
254 $basefactor = $all_units->{$form->{"selected_unit_$i"}}->{"factor"} /
255 $all_units->{$form->{"unit_old_$i"}}->{"factor"};
257 $form->{"sellprice_$i"} *= $basefactor;
258 $form->{"unit_old_$i"} = $form->{"selected_unit_$i"};
261 ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/);
263 $decimalplaces = ($dec > 2) ? $dec : 2;
267 $form->{"sellprice_$i"} * $form->{"discount_$i"} / 100,
271 $form->round_amount($form->{"sellprice_$i"} - $discount, $decimalplaces);
272 $linetotal = $form->round_amount($linetotal * $form->{"qty_$i"}, 2);
274 # convert " to "
275 map { $form->{"${_}_$i"} =~ s/\"/"/g }
276 qw(partnumber description unit unit_old);
278 ########################################
279 # Eintrag fuer Version 2.2.0 geaendert #
280 # neue Optik im Rechnungsformular #
281 ########################################
282 $column_data{runningnumber} =
283 qq|<td><input name="runningnumber_$i" size=5 value=$i></td>|; # HuT
284 ############## ENDE Neueintrag ##################
286 $column_data{partnumber} =
287 qq|<td><input name="partnumber_$i" size=12 value="$form->{"partnumber_$i"}"></td>|;
289 if (($rows = $form->numtextrows($form->{"description_$i"}, 30, 6)) > 1) {
290 $column_data{description} =
291 qq|<td><textarea name="description_$i" rows=$rows cols=30 wrap=soft>$form->{"description_$i"}</textarea><button type="button" onclick="set_longdescription_window('longdescription_$i')">| . $locale->text('L') . qq|</button></td>|;
293 $column_data{description} =
294 qq|<td><input name="description_$i" size=30 value="$form->{"description_$i"}"><button type="button" onclick="set_longdescription_window('longdescription_$i')">| . $locale->text('L') . qq|</button></td>|;
297 (my $qty_dec) = ($form->{"qty_$i"} =~ /\.(\d+)/);
298 $qty_dec = length $qty_dec;
301 qq|<td align=right><input name="qty_$i" size=5 value=|
302 . $form->format_amount(\%myconfig, $form->{"qty_$i"}, $qty_dec) .qq|>|;
303 if ($form->{"formel_$i"}) {
304 $column_data{qty} .= qq|<button type="button" onclick="calculate_qty_selection_window('qty_$i','alu_$i', 'formel_$i', $i)">| . $locale->text('*/') . qq|</button>
305 <input type=hidden name="formel_$i" value="$form->{"formel_$i"}"><input type=hidden name="alu_$i" value="$form->{"alu_$i"}"></td>|;
308 qq|<td align=right><input name="ship_$i" size=5 value=|
309 . $form->format_amount(\%myconfig, $form->{"ship_$i"})
312 my $is_part = $form->{"inventory_accno_$i"};
313 my $is_assigned = $form->{"id_$i"};
314 my $this_unit = $form->{"unit_$i"};
315 if ($form->{"selected_unit_$i"} && $this_unit &&
316 $all_units->{$form->{"selected_unit_$i"}} && $all_units->{$this_unit} &&
317 ($all_units->{$form->{"selected_unit_$i"}}->{"base_unit"} eq $all_units->{$this_unit}->{"base_unit"})) {
318 $this_unit = $form->{"selected_unit_$i"};
319 } elsif (!$is_assigned ||
320 ($is_part && !$this_unit && ($all_units->{$this_unit} && ($all_units->{$this_unit}->{"base_unit"} eq $all_units->{"kg"}->{"base_unit"})))) {
324 $column_data{"unit"} = "<td>" .
325 ($qty_readonly ? " " :
326 AM->unit_select_html($is_part ? $dimension_units :
327 $is_assigned ? $service_units : $all_units,
328 "unit_$i", $this_unit,
329 $is_assigned ? $form->{"unit_$i"} : undef))
332 # build in drop down list for pricesgroups
333 if ($form->{"prices_$i"}) {
334 if ($form->{"new_pricegroup_$i"} != $form->{"old_pricegroup_$i"}) {
335 $price_tmp = $form->format_amount(\%myconfig, $form->{"price_new_$i"}, $decimalplaces);
337 $price_tmp = $form->format_amount(\%myconfig, $form->{"sellprice_$i"}, $decimalplaces);
340 $column_data{sellprice_pg} =
341 qq|<td align=right><select name="sellprice_pg_$i">$form->{"prices_$i"}</select></td>|;
342 $column_data{sellprice} =
343 qq|<td><input name="sellprice_$i" size=10 value=$price_tmp></td>|;
346 # for last row and report
347 # set pricegroup drop down list from report menu
348 if ($form->{"sellprice_$i"} != 0) {
350 qq|<option value="$form->{"sellprice_$i"}--$form->{"pricegroup_id_$i"}" selected>$form->{"pricegroup_$i"}</option>\n|;
352 $form->{"pricegroup_old_$i"} = $form->{"pricegroup_id_$i"};
354 $column_data{sellprice_pg} =
355 qq|<td align=right><select name="sellprice_pg_$i">$prices</select></td>|;
360 $column_data{sellprice_pg} = qq|<td align=right> </td>|;
363 $column_data{sellprice} =
364 qq|<td><input name="sellprice_$i" size=10 value=|
365 . $form->format_amount(\%myconfig, $form->{"sellprice_$i"},
369 $column_data{discount} =
370 qq|<td align=right><input name="discount_$i" size=3 value=|
371 . $form->format_amount(\%myconfig, $form->{"discount_$i"})
373 $column_data{linetotal} =
375 . $form->format_amount(\%myconfig, $linetotal, 2)
377 $column_data{bin} = qq|<td>$form->{"bin_$i"}</td>|;
379 ########################################
380 # Eintrag fuer Version 2.2.0 geaendert #
381 # neue Optik im Rechnungsformular #
382 ########################################
383 # if ($lizenzen && $form->{type} eq "invoice" && $form->{vc} eq "customer") {
384 # $column_data{license} = qq|<td><select name="licensenumber_$i">$form->{"lizenzen_$i"}></select></td>|;
387 # if ($form->{type} !~ /_quotation/) {
388 # $column_data{serialnr} = qq|<td><input name="serialnumber_$i" size=10 value="$form->{"serialnumber_$i"}"></td>|;
391 # $column_data{projectnr} = qq|<td><input name="projectnumber_$i" size=10 value="$form->{"projectnumber_$i"}"></td>|;
392 ############## ENDE Neueintrag ##################
396 <tr valign=top class=listrow$j>|;
398 map { print "\n$column_data{$_}" } @column_index;
403 <input type=hidden name="orderitems_id_$i" value=$form->{"orderitems_id_$i"}>
404 <input type=hidden name="bo_$i" value=$form->{"bo_$i"}>
406 <input type=hidden name="pricegroup_old_$i" value=$form->{"pricegroup_old_$i"}>
407 <input type=hidden name="price_old_$i" value=$form->{"price_old_$i"}>
408 <input type=hidden name="unit_old_$i" value="$form->{"selected_unit_$i"}">
409 <input type=hidden name="price_new_$i" value=|
410 . $form->format_amount(\%myconfig, $form->{"price_new_$i"}) . qq|>
412 <input type=hidden name="id_$i" value=$form->{"id_$i"}>
413 <input type=hidden name="inventory_accno_$i" value=$form->{"inventory_accno_$i"}>
414 <input type=hidden name="bin_$i" value="$form->{"bin_$i"}">
415 <input type=hidden name="partsgroup_$i" value="$form->{"partsgroup_$i"}">
416 <input type=hidden name="partnotes_$i" value="$form->{"partnotes_$i"}">
417 <input type=hidden name="income_accno_$i" value=$form->{"income_accno_$i"}>
418 <input type=hidden name="expense_accno_$i" value=$form->{"expense_accno_$i"}>
419 <input type=hidden name="listprice_$i" value="$form->{"listprice_$i"}">
420 <input type=hidden name="assembly_$i" value="$form->{"assembly_$i"}">
421 <input type=hidden name="taxaccounts_$i" value="$form->{"taxaccounts_$i"}">
422 <input type=hidden name="ordnumber_$i" value="$form->{"ordnumber_$i"}">
423 <input type=hidden name="transdate_$i" value="$form->{"transdate_$i"}">
424 <input type=hidden name="cusordnumber_$i" value="$form->{"cusordnumber_$i"}">
425 <input type=hidden name="longdescription_$i" value="$form->{"longdescription_$i"}">
426 <input type=hidden name="basefactor_$i" value="$form->{"basefactor_$i"}">
430 ########################################
431 # Eintrag fuer Version 2.2.0 geaendert #
432 # neue Optik im Rechnungsformular #
433 ########################################
437 <td colspan=$colspan>
439 if ($lizenzen && $form->{type} eq "invoice" && $form->{vc} eq "customer") {
440 my $selected = $form->{"licensenumber_$i"};
442 $form->{"lizenzen_$i"} =~ s/ selected//g;
443 $form->{"lizenzen_$i"} =~
444 s/value="${selected}"\>/value="${selected}" selected\>/;
445 $lizenzen_quoted = $form->{"lizenzen_$i"};
446 $lizenzen_quoted =~ s/\"/"/g;
448 <b>Lizenz\#</b> <select name="licensenumber_$i" size=1>
449 $form->{"lizenzen_$i"}
451 <input type=hidden name="lizenzen_$i" value="${lizenzen_quoted}">
454 if ($form->{type} !~ /_quotation/) {
456 <b>$serialnumber</b> <input name="serialnumber_$i" size=15 value="$form->{"serialnumber_$i"}">|;
460 <b>$projectnumber</b> <input name="projectnumber_$i" size=10 value="$form->{"projectnumber_$i"}">
461 <input type=hidden name="oldprojectnumber_$i" value="$form->{"oldprojectnumber_$i"}">
462 <input type=hidden name="project_id_$i" value="$form->{"project_id_$i"}">
464 if ($form->{type} eq 'invoice' or $form->{type} =~ /order/) {
466 ($form->{type} eq 'invoice')
468 : 'reqdate'; # invoice uses a different term for the same thing.
470 <b>${$reqdate_term}</b> <input name="${reqdate_term}_$i" size=11 value="$form->{"${reqdate_term}_$i"}">
473 my $subtotalchecked = ($form->{"subtotal_$i"}) ? "checked" : "";
475 <b>|.$locale->text('Subtotal').qq|</b> <input type="checkbox" name="subtotal_$i" value="1" "$subtotalchecked">
481 ############## ENDE Neueintrag ##################
483 map { $form->{"${_}_base"} += $linetotal }
484 (split / /, $form->{"taxaccounts_$i"});
486 $form->{invsubtotal} += $linetotal;
495 $lxdebug->leave_sub();
498 ##################################################
499 # build html-code for pricegroups in variable $form->{prices_$j}
502 $lxdebug->enter_sub();
503 my $rowcount = shift;
504 for $j (1 .. $rowcount) {
505 my $pricegroup_old = $form->{"pricegroup_old_$i"};
506 if ($form->{PRICES}{$j}) {
508 $prices = '<option value="--">' . $locale->text("none (pricegroup)") . '</option>';
510 foreach $item (@{ $form->{PRICES}{$j} }) {
512 #$price = $form->round_amount($myconfig, $item->{price}, 5);
513 #$price = $form->format_amount($myconfig, $item->{price}, 2);
514 $price = $item->{price};
515 $pricegroup_id = $item->{pricegroup_id};
516 $pricegroup = $item->{pricegroup};
518 # build drop down list for pricegroups
520 qq|<option value="$price--$pricegroup_id"$item->{selected}>$pricegroup</option>\n|;
525 # $form->{"${_}_$j"} =
526 # $form->format_amount(\%myconfig, $form->{"${_}_$j"})
527 # } qw(sellprice price_new price_old);
529 # set new selectedpricegroup_id and prices for "Preis"
530 if ($item->{selected} && ($pricegroup_id != 0)) {
531 $form->{"pricegroup_old_$j"} = $pricegroup_id;
532 $form->{"price_new_$j"} = $price;
533 $form->{"sellprice_$j"} = $price;
535 if ($pricegroup_id == 0) {
536 $form->{"price_new_$j"} = $form->{"sellprice_$j"};
539 $form->{"prices_$j"} = $prices;
542 $lxdebug->leave_sub();
546 $lxdebug->enter_sub();
547 @column_index = qw(ndx partnumber description onhand sellprice);
549 $column_data{ndx} = qq|<th> </th>|;
550 $column_data{partnumber} =
551 qq|<th class=listheading>| . $locale->text('Number') . qq|</th>|;
552 $column_data{description} =
553 qq|<th class=listheading>| . $locale->text('Part Description') . qq|</th>|;
554 $column_data{sellprice} =
555 qq|<th class=listheading>| . $locale->text('Price') . qq|</th>|;
556 $column_data{onhand} =
557 qq|<th class=listheading>| . $locale->text('Qty') . qq|</th>|;
559 # list items with radio button on a form
562 $title = $locale->text('Select from one of the items below');
563 $colspan = $#column_index + 1;
568 <form method=post action=$form->{script}>
572 <th class=listtop colspan=$colspan>$title</th>
575 <tr class=listheading>|;
577 map { print "\n$column_data{$_}" } @column_index;
582 foreach $ref (@{ $form->{item_list} }) {
583 $checked = ($i++) ? "" : "checked";
586 if ($ref->{inventory_accno} > 0) {
587 $ref->{"lizenzen"} = qq|<option></option>|;
588 foreach $item (@{ $form->{LIZENZEN}{ $ref->{"id"} } }) {
589 $ref->{"lizenzen"} .=
590 qq|<option value=\"$item->{"id"}\">$item->{"licensenumber"}</option>|;
592 $ref->{"lizenzen"} .= qq|<option value=-1>Neue Lizenz</option>|;
593 $ref->{"lizenzen"} =~ s/\"/"/g;
597 map { $ref->{$_} =~ s/\"/"/g } qw(partnumber description unit);
601 $form->round_amount($ref->{sellprice} * (1 - $form->{tradediscount}), 2);
603 qq|<td><input name=ndx class=radio type=radio value=$i $checked></td>|;
604 $column_data{partnumber} =
605 qq|<td><input name="new_partnumber_$i" type=hidden value="$ref->{partnumber}">$ref->{partnumber}</td>|;
606 $column_data{description} =
607 qq|<td><input name="new_description_$i" type=hidden value="$ref->{description}">$ref->{description}</td>|;
608 $column_data{sellprice} =
609 qq|<td align=right><input name="new_sellprice_$i" type=hidden value=$ref->{sellprice}>|
610 . $form->format_amount(\%myconfig, $ref->{sellprice}, 2, " ")
612 $column_data{onhand} =
613 qq|<td align=right><input name="new_onhand_$i" type=hidden value=$ref->{onhand}>|
614 . $form->format_amount(\%myconfig, $ref->{onhand}, '', " ")
620 <tr class=listrow$j>|;
622 map { print "\n$column_data{$_}" } @column_index;
627 <input name="new_bin_$i" type=hidden value="$ref->{bin}">
628 <input name="new_listprice_$i" type=hidden value=$ref->{listprice}>
629 <input name="new_inventory_accno_$i" type=hidden value=$ref->{inventory_accno}>
630 <input name="new_income_accno_$i" type=hidden value=$ref->{income_accno}>
631 <input name="new_expense_accno_$i" type=hidden value=$ref->{expense_accno}>
632 <input name="new_unit_$i" type=hidden value="$ref->{unit}">
633 <input name="new_weight_$i" type=hidden value="$ref->{weight}">
634 <input name="new_assembly_$i" type=hidden value="$ref->{assembly}">
635 <input name="new_taxaccounts_$i" type=hidden value="$ref->{taxaccounts}">
636 <input name="new_partsgroup_$i" type=hidden value="$ref->{partsgroup}">
637 <input name="new_formel_$i" type=hidden value="$ref->{formel}">
638 <input name="new_alu_$i" type=hidden value="$ref->{alu}">
639 <input name="new_longdescription_$i" type=hidden value="$ref->{longdescription}">
640 <input name="new_not_discountable_$i" type=hidden value="$ref->{not_discountable}">
641 <input name="new_part_payment_id_$i" type=hidden value="$ref->{part_payment_id}">
643 <input name="new_id_$i" type=hidden value=$ref->{id}>
648 <input name="new_lizenzen_$i" type=hidden value="$ref->{lizenzen}">
655 <tr><td colspan=8><hr size=3 noshade></td></tr>
658 <input name=lastndx type=hidden value=$i>
662 # delete action variable
663 map { delete $form->{$_} } qw(action item_list header);
665 # save all other form variables
666 foreach $key (keys %${form}) {
667 $form->{$key} =~ s/\"/"/g;
668 print qq|<input name=$key type=hidden value="$form->{$key}">\n|;
672 <input type=hidden name=nextsub value=item_selected>
675 <input class=submit type=submit name=action value="|
676 . $locale->text('Continue') . qq|">
683 $lxdebug->leave_sub();
687 $lxdebug->enter_sub();
689 # replace the last row with the checked row
690 $i = $form->{rowcount};
691 $i = $form->{assembly_rows} if ($form->{item} eq 'assembly');
697 #($form->{"sellprice_$i"},$form->{"$pricegroup_old_$i"}) = split /--/, $form->{"sellprice_$i"};
698 #$form->{"sellprice_$i"} = $form->{"sellprice_$i"};
700 # if there was a price entered, override it
701 $sellprice = $form->parse_amount(\%myconfig, $form->{"sellprice_$i"});
703 map { $form->{"${_}_$i"} = $form->{"new_${_}_$j"} }
704 qw(id partnumber description sellprice listprice inventory_accno income_accno expense_accno bin unit weight assembly taxaccounts partsgroup formel alu longdescription not_discountable);
705 if ($form->{"part_payment_id_$i"} ne "") {
706 $form->{payment_id} = $form->{"part_payment_id_$i"};
710 map { $form->{"${_}_$i"} = $form->{"new_${_}_$j"} } qw(lizenzen);
713 ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/);
715 $decimalplaces = ($dec > 2) ? $dec : 2;
718 $form->{"sellprice_$i"} = $sellprice;
721 # if there is an exchange rate adjust sellprice
722 if (($form->{exchangerate} * 1) != 0) {
723 $form->{"sellprice_$i"} /= $form->{exchangerate};
724 $form->{"sellprice_$i"} =
725 $form->round_amount($form->{"sellprice_$i"}, $decimalplaces);
729 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
730 qw(sellprice listprice weight);
732 $form->{sellprice} += ($form->{"sellprice_$i"} * $form->{"qty_$i"});
733 $form->{weight} += ($form->{"weight_$i"} * $form->{"qty_$i"});
735 if ($form->{"not_discountable_$i"}) {
736 $form->{"discount_$i"} = 0;
740 $form->{"sellprice_$i"} * (1 - $form->{"discount_$i"} / 100) *
742 map { $form->{"${_}_base"} += $amount }
743 (split / /, $form->{"taxaccounts_$i"});
744 map { $amount += ($form->{"${_}_base"} * $form->{"${_}_rate"}) } split / /,
745 $form->{"taxaccounts_$i"}
746 if !$form->{taxincluded};
748 $form->{creditremaining} -= $amount;
750 $form->{"runningnumber_$i"} = $i;
752 # delete all the new_ variables
753 for $i (1 .. $form->{lastndx}) {
754 map { delete $form->{"new_${_}_$i"} }
755 qw(partnumber description sellprice bin listprice inventory_accno income_accno expense_accno unit assembly taxaccounts id);
758 map { delete $form->{$_} } qw(ndx lastndx nextsub);
763 $form->format_amount(\%myconfig, $form->{"${_}_$i"}, $decimalplaces)
764 } qw(sellprice listprice) if $form->{item} ne 'assembly';
766 # get pricegroups for parts
767 IS->get_pricegroups_for_parts(\%myconfig, \%$form);
769 # build up html code for prices_$i
770 set_pricegroup($form->{rowcount});
774 $lxdebug->leave_sub();
778 $lxdebug->enter_sub();
781 $form->{old_callback} = $form->escape($form->{callback}, 1);
782 $form->{callback} = $form->escape("$form->{script}?action=display_form", 1);
785 delete $form->{action};
787 # save all other form variables in a previousform variable
788 foreach $key (keys %$form) {
791 $form->{$key} =~ s/&/%26/g;
792 $previousform .= qq|$key=$form->{$key}&|;
795 $previousform = $form->escape($previousform, 1);
797 $i = $form->{rowcount};
798 map { $form->{"${_}_$i"} =~ s/\"/"/g } qw(partnumber description);
805 <h4 class=error>| . $locale->text('Item not on file!') . qq|
808 | . $locale->text('What type of item is this?') . qq|</h4>
810 <form method=post action=ic.pl>
814 <input class=radio type=radio name=item value=part checked> |
815 . $locale->text('Part') . qq|<br>
816 <input class=radio type=radio name=item value=service> |
817 . $locale->text('Service')
820 <input type=hidden name=previousform value="$previousform">
821 <input type=hidden name=partnumber value="$form->{"partnumber_$i"}">
822 <input type=hidden name=description value="$form->{"description_$i"}">
823 <input type=hidden name=rowcount value=$form->{rowcount}>
824 <input type=hidden name=taxaccount2 value=$form->{taxaccounts}>
825 <input type=hidden name=vc value=$form->{vc}>
827 <input type=hidden name=path value=$form->{path}>
828 <input type=hidden name=login value=$form->{login}>
829 <input type=hidden name=password value=$form->{password}>
831 <input type=hidden name=nextsub value=add>
834 <input class=submit type=submit name=action value="|
835 . $locale->text('Continue') . qq|">
842 $lxdebug->leave_sub();
846 $lxdebug->enter_sub();
847 $form->language_payment(\%myconfig);
849 # if we have a display_form
850 if ($form->{display_form}) {
851 &{"$form->{display_form}"};
855 # if ( $form->{print_and_post}
856 # && $form->{second_run}
857 # && ($form->{action} eq "display_form")) {
858 # for (keys %$form) { $old_form->{$_} = $form->{$_} }
859 # $old_form->{rowcount}++;
861 # #$form->{rowcount}--;
862 # #$form->{rowcount}--;
864 # $form->{print_and_post} = 0;
866 # &print_form($old_form);
870 # $form->{action} = "";
871 # $form->{resubmit} = 0;
873 # if ($form->{print_and_post} && !$form->{second_run}) {
874 # $form->{second_run} = 1;
875 # $form->{action} = "display_form";
876 # $form->{rowcount}--;
877 # my $rowcount = $form->{rowcount};
879 # # get pricegroups for parts
880 # IS->get_pricegroups_for_parts(\%myconfig, \%$form);
882 # # build up html code for prices_$i
883 # set_pricegroup($rowcount);
885 # $form->{resubmit} = 1;
890 $numrows = ++$form->{rowcount};
891 $subroutine = "display_row";
893 if ($form->{item} eq 'part') {
895 #set preisgruppenanzahl
896 $numrows = $form->{price_rows};
897 $subroutine = "price_row";
899 &{$subroutine}($numrows);
901 $numrows = ++$form->{makemodel_rows};
902 $subroutine = "makemodel_row";
904 if ($form->{item} eq 'assembly') {
905 $numrows = $form->{price_rows};
906 $subroutine = "price_row";
908 &{$subroutine}($numrows);
910 $numrows = ++$form->{makemodel_rows};
911 $subroutine = "makemodel_row";
913 # create makemodel rows
914 &{$subroutine}($numrows);
916 $numrows = ++$form->{assembly_rows};
917 $subroutine = "assembly_row";
919 if ($form->{item} eq 'service') {
920 $numrows = $form->{price_rows};
921 $subroutine = "price_row";
923 &{$subroutine}($numrows);
929 &{$subroutine}($numrows) if $numrows;
933 $lxdebug->leave_sub();
937 $lxdebug->enter_sub();
941 qw(id partnumber description qty ship sellprice unit discount inventory_accno income_accno expense_accno listprice taxaccounts bin assembly weight projectnumber project_id oldprojectnumber runningnumber serialnumber partsgroup payment_id not_discountable shop ve gv buchungsgruppen_id language_values)
945 # remove any makes or model rows
946 if ($form->{item} eq 'part') {
947 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
948 qw(listprice sellprice lastcost weight rop);
950 @flds = (make, model);
951 for my $i (1 .. ($form->{makemodel_rows})) {
952 if (($form->{"make_$i"} ne "") || ($form->{"model_$i"} ne "")) {
956 map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
961 $form->redo_rows(\@flds, \@a, $count, $form->{makemodel_rows});
962 $form->{makemodel_rows} = $count;
964 } elsif ($form->{item} eq 'assembly') {
966 $form->{sellprice} = 0;
968 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
969 qw(listprice rop stock);
972 qw(id qty unit bom partnumber description sellprice weight runningnumber partsgroup);
974 for my $i (1 .. ($form->{assembly_rows} - 1)) {
975 if ($form->{"qty_$i"}) {
979 $form->{"qty_$i"} = $form->parse_amount(\%myconfig, $form->{"qty_$i"});
981 map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
983 #($form->{"sellprice_$i"},$form->{"$pricegroup_old_$i"}) = split /--/, $form->{"sellprice_$i"};
985 $form->{sellprice} += ($form->{"qty_$i"} * $form->{"sellprice_$i"});
986 $form->{weight} += ($form->{"qty_$i"} * $form->{"weight_$i"});
991 $form->{sellprice} = $form->round_amount($form->{sellprice}, 2);
993 $form->redo_rows(\@flds, \@a, $count, $form->{assembly_rows});
994 $form->{assembly_rows} = $count;
997 @flds = qw(make model);
1000 for my $i (1 .. ($form->{makemodel_rows})) {
1001 if (($form->{"make_$i"} ne "") || ($form->{"model_$i"} ne "")) {
1005 map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
1010 $form->redo_rows(\@flds, \@a, $count, $form->{makemodel_rows});
1011 $form->{makemodel_rows} = $count;
1015 # this section applies to invoices and orders
1016 # remove any empty numbers
1017 if ($form->{rowcount}) {
1018 for my $i (1 .. $form->{rowcount} - 1) {
1019 if ($form->{"partnumber_$i"}) {
1023 map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
1026 if ($form->{"licensenumber_$i"} == -1) {
1034 $form->redo_rows(\@flds, \@a, $count, $form->{rowcount});
1035 $form->{rowcount} = $count;
1037 $form->{creditremaining} -= &invoicetotal;
1044 if ( $form->{type} =~ (/sales_quotation/)
1045 or (($form->{level} =~ /Sales/) and ($form->{type} =~ /invoice/))
1046 or (($form->{level} eq undef) and ($form->{type} =~ /invoice/))
1047 or ($form->{type} =~ /sales_order/)) {
1049 # get pricegroups for parts
1050 IS->get_pricegroups_for_parts(\%myconfig, \%$form);
1052 # build up html code for prices_$i
1053 set_pricegroup($form->{rowcount});
1059 $lxdebug->leave_sub();
1063 $lxdebug->enter_sub();
1065 $form->{oldinvtotal} = 0;
1067 # add all parts and deduct paid
1068 map { $form->{"${_}_base"} = 0 } split / /, $form->{taxaccounts};
1070 my ($amount, $sellprice, $discount, $qty);
1072 for my $i (1 .. $form->{rowcount}) {
1073 $sellprice = $form->parse_amount(\%myconfig, $form->{"sellprice_$i"});
1074 $discount = $form->parse_amount(\%myconfig, $form->{"discount_$i"});
1075 $qty = $form->parse_amount(\%myconfig, $form->{"qty_$i"});
1077 #($form->{"sellprice_$i"}, $form->{"$pricegroup_old_$i"}) = split /--/, $form->{"sellprice_$i"};
1079 $amount = $sellprice * (1 - $discount / 100) * $qty;
1080 map { $form->{"${_}_base"} += $amount }
1081 (split / /, $form->{"taxaccounts_$i"});
1082 $form->{oldinvtotal} += $amount;
1085 map { $form->{oldinvtotal} += ($form->{"${_}_base"} * $form->{"${_}_rate"}) }
1086 split / /, $form->{taxaccounts}
1087 if !$form->{taxincluded};
1089 $form->{oldtotalpaid} = 0;
1090 for $i (1 .. $form->{paidaccounts}) {
1091 $form->{oldtotalpaid} += $form->{"paid_$i"};
1094 $lxdebug->leave_sub();
1097 return ($form->{oldinvtotal} - $form->{oldtotalpaid});
1100 sub validate_items {
1101 $lxdebug->enter_sub();
1103 # check if items are valid
1104 if ($form->{rowcount} == 1) {
1109 for $i (1 .. $form->{rowcount} - 1) {
1110 $form->isblank("partnumber_$i",
1111 $locale->text('Number missing in Row') . " $i");
1114 $lxdebug->leave_sub();
1118 $lxdebug->enter_sub();
1119 if ($form->{second_run}) {
1120 $form->{print_and_post} = 0;
1122 $form->{ordnumber} = $form->{invnumber};
1124 map { delete $form->{$_} } qw(id printed emailed queued);
1125 if ($form->{script} eq 'ir.pl' || $form->{type} eq 'request_quotation') {
1126 $form->{title} = $locale->text('Add Purchase Order');
1127 $form->{vc} = 'vendor';
1128 $form->{type} = 'purchase_order';
1131 if ($form->{script} eq 'is.pl' || $form->{type} eq 'sales_quotation') {
1132 $form->{title} = $locale->text('Add Sales Order');
1133 $form->{vc} = 'customer';
1134 $form->{type} = 'sales_order';
1137 $form->{script} = 'oe.pl';
1139 $form->{shipto} = 1;
1141 $form->{rowcount}--;
1143 $form->{cp_id} *= 1;
1145 require "$form->{path}/$form->{script}";
1147 map { $form->{"select$_"} = "" } ($form->{vc}, currency);
1149 $currency = $form->{currency};
1153 $form->{currency} = $currency;
1154 $form->{exchangerate} = "";
1155 $form->{forex} = "";
1156 $form->{exchangerate} = $exchangerate
1160 $form->check_exchangerate(
1161 \%myconfig, $form->{currency}, $form->{transdate}, $buysell
1167 $lxdebug->leave_sub();
1171 $lxdebug->enter_sub();
1172 if ($form->{second_run}) {
1173 $form->{print_and_post} = 0;
1175 map { delete $form->{$_} } qw(id printed emailed queued);
1177 if ($form->{script} eq 'ir.pl' || $form->{type} eq 'purchase_order') {
1178 $form->{title} = $locale->text('Add Request for Quotation');
1179 $form->{vc} = 'vendor';
1180 $form->{type} = 'request_quotation';
1183 if ($form->{script} eq 'is.pl' || $form->{type} eq 'sales_order') {
1184 $form->{title} = $locale->text('Add Quotation');
1185 $form->{vc} = 'customer';
1186 $form->{type} = 'sales_quotation';
1190 $form->{cp_id} *= 1;
1192 $form->{script} = 'oe.pl';
1194 $form->{shipto} = 1;
1196 $form->{rowcount}--;
1198 require "$form->{path}/$form->{script}";
1200 map { $form->{"select$_"} = "" } ($form->{vc}, currency);
1202 $currency = $form->{currency};
1206 $form->{currency} = $currency;
1207 $form->{exchangerate} = "";
1208 $form->{forex} = "";
1209 $form->{exchangerate} = $exchangerate
1213 $form->check_exchangerate(
1214 \%myconfig, $form->{currency}, $form->{transdate}, $buysell
1220 $lxdebug->leave_sub();
1224 $lxdebug->enter_sub();
1225 if ($form->{second_run}) {
1226 $form->{print_and_post} = 0;
1227 $form->{resubmit} = 0;
1229 if ($myconfig{role} eq 'admin') {
1231 <th align=right nowrap=true>| . $locale->text('Bcc') . qq|</th>
1232 <td><input name=bcc size=30 value="$form->{bcc}"></td>
1236 if ($form->{formname} =~ /(pick|packing|bin)_list/) {
1237 $form->{email} = $form->{shiptoemail} if $form->{shiptoemail};
1240 $name = $form->{ $form->{vc} };
1242 $title = $locale->text('E-mail') . " $name";
1244 $form->{oldmedia} = $form->{media};
1245 $form->{media} = "email";
1252 <form method=post action=$form->{script}>
1256 <th class=listtop>$title</th>
1258 <tr height="5"></tr>
1263 <th align=right nowrap>| . $locale->text('To') . qq|</th>
1264 <td><input name=email size=30 value="$form->{email}"></td>
1265 <th align=right nowrap>| . $locale->text('Cc') . qq|</th>
1266 <td><input name=cc size=30 value="$form->{cc}"></td>
1269 <th align=right nowrap>| . $locale->text('Subject') . qq|</th>
1270 <td><input name=subject size=30 value="$form->{subject}"></td>
1280 <th align=left nowrap>| . $locale->text('Message') . qq|</th>
1283 <td><textarea name=message rows=15 cols=60 wrap=soft>$form->{message}</textarea></td>
1294 map { delete $form->{$_} }
1295 qw(action email cc bcc subject message formname sendmode format header override);
1297 # save all other variables
1298 foreach $key (keys %$form) {
1299 $form->{$key} =~ s/\"/"/g;
1300 print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
1307 <td><hr size=3 noshade></td>
1311 <input type=hidden name=nextsub value=send_email>
1314 <input name=action class=submit type=submit value="|
1315 . $locale->text('Continue') . qq|">
1322 $lxdebug->leave_sub();
1326 $lxdebug->enter_sub();
1328 $old_form = new Form;
1330 map { $old_form->{$_} = $form->{$_} } keys %$form;
1331 $old_form->{media} = $form->{oldmedia};
1333 &print_form($old_form);
1335 $lxdebug->leave_sub();
1339 $lxdebug->enter_sub();
1340 $form->{sendmode} = "attachment";
1341 $form->{copies} = 3 unless $form->{copies};
1343 $form->{PD}{ $form->{formname} } = "selected";
1344 $form->{DF}{ $form->{format} } = "selected";
1345 $form->{OP}{ $form->{media} } = "selected";
1346 $form->{SM}{ $form->{sendmode} } = "selected";
1348 if ($form->{type} eq 'purchase_order') {
1349 $type = qq|<select name=formname>
1350 <option value=purchase_order $form->{PD}{purchase_order}>|
1351 . $locale->text('Purchase Order') . qq|
1352 <option value=bin_list $form->{PD}{bin_list}>|
1353 . $locale->text('Bin List');
1356 if ($form->{type} eq 'credit_note') {
1357 $type = qq|<select name=formname>
1358 <option value=credit_note $form->{PD}{credit_note}>|
1359 . $locale->text('Credit Note');
1362 if ($form->{type} eq 'sales_order') {
1363 $type = qq|<select name=formname>
1364 <option value=sales_order $form->{PD}{sales_order}>|
1365 . $locale->text('Confirmation') . qq|
1366 <option value=proforma $form->{PD}{proforma}>|
1367 . $locale->text('Proforma Invoice') . qq|
1368 <option value=pick_list $form->{PD}{pick_list}>|
1369 . $locale->text('Pick List') . qq|
1370 <option value=packing_list $form->{PD}{packing_list}>|
1371 . $locale->text('Packing List');
1374 if ($form->{type} =~ /_quotation$/) {
1375 $type = qq|<select name=formname>
1376 <option value="$`_quotation" $form->{PD}{"$`_quotation"}>|
1377 . $locale->text('Quotation');
1380 if ($form->{type} eq 'invoice') {
1381 $type = qq|<select name=formname>
1382 <option value=invoice $form->{PD}{invoice}>|
1383 . $locale->text('Invoice') . qq|
1384 <option value=proforma $form->{PD}{proforma}>|
1385 . $locale->text('Proforma Invoice') . qq|
1386 <option value=packing_list $form->{PD}{packing_list}>|
1387 . $locale->text('Packing List');
1390 if ($form->{type} eq 'invoice' && $form->{storno}) {
1391 $type = qq|<select name=formname>
1392 <option value=storno_invoice $form->{PD}{storno_invoice}>|
1393 . $locale->text('Storno Invoice') . qq|
1394 <option value=storno_packing_list $form->{PD}{storno_packing_list}>|
1395 . $locale->text('Storno Packing List');
1398 if ($form->{type} eq 'credit_note') {
1399 $type = qq|<select name=formname>
1400 <option value=credit_note $form->{PD}{credit_note}>|
1401 . $locale->text('Credit Note');
1404 if ($form->{type} eq 'ship_order') {
1405 $type = qq|<select name=formname>
1406 <option value=pick_list $form->{PD}{pick_list}>|
1407 . $locale->text('Pick List') . qq|
1408 <option value=packing_list $form->{PD}{packing_list}>|
1409 . $locale->text('Packing List');
1412 if ($form->{type} eq 'receive_order') {
1413 $type = qq|<select name=formname>
1414 <option value=bin_list $form->{PD}{bin_list}>|
1415 . $locale->text('Bin List');
1418 if ($form->{media} eq 'email') {
1419 $media = qq|<select name=sendmode>
1420 <option value=attachment $form->{SM}{attachment}>|
1421 . $locale->text('Attachment') . qq|
1422 <option value=inline $form->{SM}{inline}>| . $locale->text('In-line');
1424 $media = qq|<select name=media>
1425 <option value=screen $form->{OP}{screen}>| . $locale->text('Screen');
1426 if (scalar(keys (%{ $form->{printers} })) !=0 && $latex_templates) {
1428 <option value=printer $form->{OP}{printer}>|
1429 . $locale->text('Printer');
1431 if ($latex_templates) {
1433 <option value=queue $form->{OP}{queue}>| . $locale->text('Queue');
1437 $format = qq|<select name=format>|;
1438 if ($opendocument_templates && $openofficeorg_writer_bin &&
1439 $xvfb_bin && (-x $openofficeorg_writer_bin) && (-x $xvfb_bin)) {
1440 $format .= qq|<option value=opendocument_pdf | .
1441 $form->{DF}{"opendocument_pdf"} . qq|>| .
1442 $locale->text("PDF (OpenDocument/OASIS)") . qq|</option>|;
1445 if ($latex_templates) {
1446 $format .= qq|<option value=pdf $form->{DF}{pdf}>| .
1447 $locale->text('PDF') . qq|</option>|;
1450 $format .= qq|<option value=html $form->{DF}{html}>HTML</option>|;
1453 $format .= qq|<option value=postscript $form->{DF}{postscript}>| .
1454 $locale->text('Postscript') . qq|</option>|;
1457 if ($opendocument_templates) {
1458 $format .= qq|<option value=opendocument $form->{DF}{opendocument}>| .
1459 $locale->text("OpenDocument/OASIS") . qq|</option>|;
1461 $format .= qq|</select>|;
1463 if (scalar(keys (%{ $form->{languages} })) !=0) {
1465 $language_select = qq|<select name=language_id>|;
1466 foreach $item (@{ $form->{languages} }) {
1467 if ($form->{language_id} eq $item->{id}) {
1468 $language_select .= qq|<option value="$item->{id}" selected>$item->{description}</option>|;
1470 $language_select .= qq|<option value="$item->{id}">$item->{description}</option>|;
1475 if (scalar(keys (%{ $form->{printers} })) !=0) {
1477 $printer_select = qq|<select name=printer_id>
1478 <option value=""></option>|;
1479 foreach $item (@{ $form->{printers} }) {
1480 $printer_select .= qq|<option value="$item->{id}">$item->{printer_description}</option>|;
1487 <table width=100% cellspacing=0 cellpadding=0>
1492 <td>$type</select></td>|;
1493 if (scalar(keys (%{ $form->{languages} })) !=0) {
1495 <td>${language_select}</select></td>|;
1498 <td>$format</select></td>
1499 <td>$media</select></td>|;
1500 if (scalar(keys (%{ $form->{printers} })) !=0) {
1502 <td>$printer_select</select></td>
1506 if (scalar(keys (%{ $form->{printers} })) !=0 && $latex_templates && $form->{media} ne 'email') {
1508 <td>| . $locale->text('Copies') . qq|
1509 <input name=copies size=2 value=$form->{copies}></td>
1513 $form->{groupitems} = "checked" if $form->{groupitems};
1516 <td>| . $locale->text('Group Items') . qq|</td>
1517 <td><input name=groupitems type=checkbox class=checkbox $form->{groupitems}></td>
1526 if ($form->{printed} =~ /$form->{formname}/) {
1528 <th>\|| . $locale->text('Printed') . qq|\|</th>
1532 if ($form->{emailed} =~ /$form->{formname}/) {
1534 <th>\|| . $locale->text('E-mailed') . qq|\|</th>
1538 if ($form->{queued} =~ /$form->{formname}/) {
1540 <th>\|| . $locale->text('Queued') . qq|\|</th>
1552 $lxdebug->leave_sub();
1556 $lxdebug->enter_sub();
1558 # if this goes to the printer pass through
1559 if ($form->{media} eq 'printer' || $form->{media} eq 'queue') {
1560 $form->error($locale->text('Select postscript or PDF!'))
1561 if ($form->{format} !~ /(postscript|pdf)/);
1563 $old_form = new Form;
1564 map { $old_form->{$_} = $form->{$_} } keys %$form;
1567 if (!$form->{id} || (($form->{formname} eq "proforma") && !$form->{proforma} && (($form->{type} =~ /_order$/) || ($form->{type} =~ /_quotation$/)))) {
1568 if ($form->{formname} eq "proforma") {
1569 $form->{proforma} = 1;
1571 $form->{print_and_save} = 1;
1572 my $formname = $form->{formname};
1574 $form->{formname} = $formname;
1579 &print_form($old_form);
1581 $lxdebug->leave_sub();
1585 $lxdebug->enter_sub();
1586 my ($old_form) = @_;
1590 $numberfld = "invnumber";
1593 ($form->{display_form}) ? $form->{display_form} : "display_form";
1595 # $form->{"notes"} will be overridden by the customer's/vendor's "notes" field. So save it here.
1596 $form->{ $form->{"formname"} . "notes" } = $form->{"notes"};
1598 if ($form->{formname} eq "invoice") {
1599 $form->{label} = $locale->text('Invoice');
1601 if ($form->{formname} eq "packing_list") {
1603 # this is from an invoice
1604 $form->{label} = $locale->text('Packing List');
1606 if ($form->{formname} eq 'sales_order') {
1609 $form->{"${inv}date"} = $form->{transdate};
1610 $form->{label} = $locale->text('Sales Order');
1611 $numberfld = "sonumber";
1615 if (($form->{type} eq 'invoice') && ($form->{formname} eq 'proforma') ) {
1618 $form->{"${inv}date"} = $form->{transdate};
1619 $form->{"invdate"} = $form->{transdate};
1620 $form->{label} = $locale->text('Proforma Invoice');
1621 $numberfld = "sonumber";
1625 if (($form->{type} eq 'sales_order') && ($form->{formname} eq 'proforma') ) {
1628 $form->{"${inv}date"} = $form->{transdate};
1629 $form->{"invdate"} = $form->{transdate};
1630 $form->{invnumber} = $form->{ordnumber};
1631 $form->{label} = $locale->text('Proforma Invoice');
1632 $numberfld = "sonumber";
1636 if ($form->{formname} eq 'packing_list' && $form->{type} ne 'invoice') {
1638 # we use the same packing list as from an invoice
1641 $form->{invdate} = $form->{"${inv}date"} = $form->{transdate};
1642 $form->{label} = $locale->text('Packing List');
1644 # set invnumber for template packing_list
1645 $form->{invnumber} = $form->{ordnumber};
1647 if ($form->{formname} eq 'pick_list') {
1650 $form->{"${inv}date"} =
1651 ($form->{transdate}) ? $form->{transdate} : $form->{invdate};
1652 $form->{label} = $locale->text('Pick List');
1653 $order = 1 unless $form->{type} eq 'invoice';
1655 if ($form->{formname} eq 'purchase_order') {
1658 $form->{"${inv}date"} = $form->{transdate};
1659 $form->{label} = $locale->text('Purchase Order');
1660 $numberfld = "ponumber";
1663 if ($form->{formname} eq 'bin_list') {
1666 $form->{"${inv}date"} = $form->{transdate};
1667 $form->{label} = $locale->text('Bin List');
1670 if ($form->{formname} eq 'sales_quotation') {
1673 $form->{"${inv}date"} = $form->{transdate};
1674 $form->{label} = $locale->text('Quotation');
1675 $numberfld = "sqnumber";
1679 if (($form->{type} eq 'sales_quotation') && ($form->{formname} eq 'proforma') ) {
1682 $form->{"${inv}date"} = $form->{transdate};
1683 $form->{"invdate"} = $form->{transdate};
1684 $form->{label} = $locale->text('Proforma Invoice');
1685 $numberfld = "sqnumber";
1689 if ($form->{formname} eq 'request_quotation') {
1692 $form->{"${inv}date"} = $form->{transdate};
1693 $form->{label} = $locale->text('Quotation');
1694 $numberfld = "rfqnumber";
1698 $form->isblank("email", $locale->text('E-mail address missing!'))
1699 if ($form->{media} eq 'email');
1700 $form->isblank("${inv}date",
1701 $locale->text($form->{label} . ' Date missing!'));
1703 # $locale->text('Invoice Number missing!')
1704 # $locale->text('Invoice Date missing!')
1705 # $locale->text('Packing List Number missing!')
1706 # $locale->text('Packing List Date missing!')
1707 # $locale->text('Order Number missing!')
1708 # $locale->text('Order Date missing!')
1709 # $locale->text('Quotation Number missing!')
1710 # $locale->text('Quotation Date missing!')
1713 if (!$form->{"${inv}number"} && !$form->{preview}) {
1714 $form->{"${inv}number"} = $form->update_defaults(\%myconfig, $numberfld);
1715 if ($form->{media} ne 'email') {
1717 # get pricegroups for parts
1718 IS->get_pricegroups_for_parts(\%myconfig, \%$form);
1720 # build up html code for prices_$i
1721 set_pricegroup($form->{rowcount});
1723 $form->{rowcount}--;
1732 # Save the email address given in the form because it should override the setting saved for the customer/vendor.
1733 my ($saved_email, $saved_cc, $saved_bcc) =
1734 ($form->{"email"}, $form->{"cc"}, $form->{"bcc"});
1736 $language_saved = $form->{language_id};
1737 &{"$form->{vc}_details"};
1738 $form->{language_id} = $language_saved;
1740 $form->{"email"} = $saved_email if ($saved_email);
1741 $form->{"cc"} = $saved_cc if ($saved_cc);
1742 $form->{"bcc"} = $saved_bcc if ($saved_bcc);
1744 # format payment dates
1745 for $i (1 .. $form->{paidaccounts} - 1) {
1746 $form->{"datepaid_$i"} = $locale->date(\%myconfig, $form->{"datepaid_$i"});
1749 ($form->{employee}) = split /--/, $form->{employee};
1750 ($form->{warehouse}, $form->{warehouse_id}) = split /--/, $form->{warehouse};
1752 # create the form variables
1754 OE->order_details(\%myconfig, \%$form);
1756 IS->invoice_details(\%myconfig, \%$form, $locale);
1759 # format global dates
1760 map { $form->{$_} = $locale->date(\%myconfig, $form->{$_}, 1) }
1761 ("${inv}date", "${due}date", "shippingdate", "deliverydate");
1764 for my $field (qw(transdate_oe deliverydate_oe)) {
1766 $form->{$field}[$_] = $locale->date(\%myconfig, $form->{$field}[$_], 1);
1767 } 0 .. $#{ $form->{$field} };
1770 if ($form->{shipto_id}) {
1771 $form->get_shipto(\%myconfig);
1774 @a = qw(name street zipcode city country);
1778 # if there is no shipto fill it in from billto
1779 foreach $item (@a) {
1780 if ($form->{"shipto$item"}) {
1787 if ( $form->{formname} eq 'purchase_order'
1788 || $form->{formname} eq 'request_quotation') {
1789 $form->{shiptoname} = $myconfig{company};
1790 $form->{shiptostreet} = $myconfig{address};
1792 map { $form->{"shipto$_"} = $form->{$_} } @a;
1796 $form->{notes} =~ s/^\s+//g;
1798 map({ $form->{$_} =~ s/\\n/\n/g; } qw(company address));
1800 $form->{templates} = "$myconfig{templates}";
1802 $form->{language} = $form->get_template_language(\%myconfig);
1803 $form->{printer_code} = $form->get_printer_code(\%myconfig);
1805 if ($form->{language} ne "") {
1806 $form->{language} = "_" . $form->{language};
1809 if ($form->{printer_code} ne "") {
1810 $form->{printer_code} = "_" . $form->{printer_code};
1813 $form->{IN} = "$form->{formname}$form->{language}$form->{printer_code}.html";
1814 if ($form->{format} eq 'postscript') {
1815 $form->{postscript} = 1;
1816 $form->{IN} =~ s/html$/tex/;
1817 } elsif ($form->{"format"} =~ /pdf/) {
1819 if ($form->{"format"} =~ /opendocument/) {
1820 $form->{IN} =~ s/html$/odt/;
1822 $form->{IN} =~ s/html$/tex/;
1824 } elsif ($form->{"format"} =~ /opendocument/) {
1825 $form->{"opendocument"} = 1;
1826 $form->{"IN"} =~ s/html$/odt/;
1829 if ($form->{media} eq 'printer') {
1830 $form->{OUT} = "| $form->{printer_command} &>/dev/null";
1831 $form->{printed} .= " $form->{formname}";
1832 $form->{printed} =~ s/^ //;
1834 $printed = $form->{printed};
1836 if ($form->{media} eq 'email') {
1837 $form->{subject} = qq|$form->{label} $form->{"${inv}number"}|
1838 unless $form->{subject};
1840 $form->{OUT} = "$sendmail";
1842 $form->{emailed} .= " $form->{formname}";
1843 $form->{emailed} =~ s/^ //;
1845 $emailed = $form->{emailed};
1847 if ($form->{media} eq 'queue') {
1848 %queued = split / /, $form->{queued};
1850 if ($filename = $queued{ $form->{formname} }) {
1851 $form->{queued} =~ s/$form->{formname} $filename//;
1852 unlink "$spool/$filename";
1853 $filename =~ s/\..*$//g;
1859 $filename .= ($form->{postscript}) ? '.ps' : '.pdf';
1860 $form->{OUT} = ">$spool/$filename";
1863 $form->{queued} .= " $form->{formname} $filename";
1865 $form->{queued} =~ s/^ //;
1867 $queued = $form->{queued};
1869 $form->parse_template(\%myconfig, $userspath);
1871 $form->{callback} = "";
1873 if ($form->{media} eq 'email') {
1874 $form->{message} = $locale->text('sent') unless $form->{message};
1876 $message = $form->{message};
1878 # if we got back here restore the previous form
1879 if ($form->{media} =~ /(printer|email|queue)/) {
1881 $form->update_status(\%myconfig)
1882 if ($form->{media} eq 'queue' && $form->{id});
1886 $old_form->{"${inv}number"} = $form->{"${inv}number"};
1888 # restore and display form
1889 map { $form->{$_} = $old_form->{$_} } keys %$old_form;
1891 $form->{queued} = $queued;
1892 $form->{printed} = $printed;
1893 $form->{emailed} = $emailed;
1894 $form->{message} = $message;
1896 $form->{rowcount}--;
1897 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
1898 qw(exchangerate creditlimit creditremaining);
1900 for $i (1 .. $form->{paidaccounts}) {
1902 $form->{"${_}_$i"} =
1903 $form->parse_amount(\%myconfig, $form->{"${_}_$i"})
1904 } qw(paid exchangerate);
1912 ($form->{media} eq 'printer')
1913 ? $locale->text('sent to printer')
1914 : $locale->text('emailed to') . " $form->{email}";
1915 $form->redirect(qq|$form->{label} $form->{"${inv}number"} $msg|);
1917 if ($form->{printing}) {
1922 $lxdebug->leave_sub();
1925 sub customer_details {
1926 $lxdebug->enter_sub();
1927 IS->customer_details(\%myconfig, \%$form);
1928 $lxdebug->leave_sub();
1931 sub vendor_details {
1932 $lxdebug->enter_sub();
1934 IR->vendor_details(\%myconfig, \%$form);
1936 $lxdebug->leave_sub();
1940 $lxdebug->enter_sub();
1942 $form->{postasnew} = 1;
1943 map { delete $form->{$_} } qw(printed emailed queued);
1947 $lxdebug->leave_sub();
1951 $lxdebug->enter_sub();
1952 if ($form->{second_run}) {
1953 $form->{print_and_post} = 0;
1956 $title = $form->{title};
1957 $form->{title} = $locale->text('Ship to');
1959 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
1960 qw(exchangerate creditlimit creditremaining);
1962 # get details for name
1963 &{"$form->{vc}_details"};
1966 ($form->{vc} eq 'customer')
1967 ? $locale->text('Customer Number')
1968 : $locale->text('Vendor Number');
1970 # get pricegroups for parts
1971 IS->get_pricegroups_for_parts(\%myconfig, \%$form);
1973 # build up html code for prices_$i
1974 set_pricegroup($form->{rowcount});
1976 $nextsub = ($form->{display_form}) ? $form->{display_form} : "display_form";
1978 $form->{rowcount}--;
1985 <form method=post action=$form->{script}>
1991 <tr class=listheading>
1992 <th class=listheading colspan=2 width=50%>|
1993 . $locale->text('Billing Address') . qq|</th>
1994 <th class=listheading width=50%>|
1995 . $locale->text('Shipping Address') . qq|</th>
1997 <tr height="5"></tr>
1999 <th align=right nowrap>$number</th>
2000 <td>$form->{"$form->{vc}number"}</td>
2003 <th align=right nowrap>| . $locale->text('Company Name') . qq|</th>
2004 <td>$form->{name}</td>
2005 <td><input name=shiptoname size=35 value="$form->{shiptoname}"></td>
2008 <th align=right nowrap>| . $locale->text('Street') . qq|</th>
2009 <td>$form->{street}</td>
2010 <td><input name=shiptostreet size=35 value="$form->{shiptostreet}"></td>
2013 <th align=right nowrap>| . $locale->text('Zipcode') . qq|</th>
2014 <td>$form->{zipcode}</td>
2015 <td><input name=shiptozipcode size=35 value="$form->{shiptozipcode}"></td>
2018 <th align=right nowrap>| . $locale->text('City') . qq|</th>
2019 <td>$form->{city}</td>
2020 <td><input name=shiptocity size=35 value="$form->{shiptocity}"></td>
2023 <th align=right nowrap>| . $locale->text('Country') . qq|</th>
2024 <td>$form->{country}</td>
2025 <td><input name=shiptocountry size=35 value="$form->{shiptocountry}"></td>
2028 <th align=right nowrap>| . $locale->text('Contact') . qq|</th>
2029 <td>$form->{contact}</td>
2030 <td><input name=shiptocontact size=35 value="$form->{shiptocontact}"></td>
2033 <th align=right nowrap>| . $locale->text('Phone') . qq|</th>
2034 <td>$form->{"$form->{vc}phone"}</td>
2035 <td><input name=shiptophone size=20 value="$form->{shiptophone}"></td>
2038 <th align=right nowrap>| . $locale->text('Fax') . qq|</th>
2039 <td>$form->{"$form->{vc}fax"}</td>
2040 <td><input name=shiptofax size=20 value="$form->{shiptofax}"></td>
2043 <th align=right nowrap>| . $locale->text('E-mail') . qq|</th>
2044 <td>$form->{email}</td>
2045 <td><input name=shiptoemail size=35 value="$form->{shiptoemail}"></td>
2052 <input type=hidden name=nextsub value=$nextsub>
2056 map { delete $form->{$_} }
2057 qw(shiptoname shiptostreet shiptozipcode shiptocity shiptocountry shiptocontact shiptophone shiptofax shiptoemail header);
2058 $form->{title} = $title;
2060 foreach $key (keys %$form) {
2061 $form->{$key} =~ s/\"/"/g;
2062 print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
2070 <input class=submit type=submit name=action value="|
2071 . $locale->text('Continue') . qq|">
2078 $lxdebug->leave_sub();
2082 $lxdebug->enter_sub();
2087 $form->{old_callback} = $form->escape($form->{callback}, 1);
2088 $form->{callback} = $form->escape("$form->{script}?action=display_form", 1);
2089 $form->{old_callback} = $form->escape($form->{old_callback}, 1);
2092 delete $form->{action};
2093 $customer = $form->{customer};
2094 map { $form->{"old_$_"} = $form->{"${_}_$row"} } qw(partnumber description);
2096 # save all other form variables in a previousform variable
2097 $form->{row} = $row;
2098 foreach $key (keys %$form) {
2101 $form->{$key} =~ s/&/%26/g;
2102 $previousform .= qq|$key=$form->{$key}&|;
2105 $previousform = $form->escape($previousform, 1);
2107 $form->{script} = "licenses.pl";
2109 map { $form->{$_} = $form->{"old_$_"} } qw(partnumber description);
2110 map { $form->{$_} = $form->escape($form->{$_}, 1) }
2111 qw(partnumber description);
2113 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|;
2116 $lxdebug->leave_sub();