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 #######################################################################
38 # any custom scripts for this one
39 if (-f "$form->{path}/custom_io.pl") {
40 eval { require "$form->{path}/custom_io.pl"; };
42 if (-f "$form->{path}/$form->{login}_io.pl") {
43 eval { require "$form->{path}/$form->{login}_io.pl"; };
50 # this is for our long dates
51 # $locale->text('January')
52 # $locale->text('February')
53 # $locale->text('March')
54 # $locale->text('April')
55 # $locale->text('May ')
56 # $locale->text('June')
57 # $locale->text('July')
58 # $locale->text('August')
59 # $locale->text('September')
60 # $locale->text('October')
61 # $locale->text('November')
62 # $locale->text('December')
64 # this is for our short month
65 # $locale->text('Jan')
66 # $locale->text('Feb')
67 # $locale->text('Mar')
68 # $locale->text('Apr')
69 # $locale->text('May')
70 # $locale->text('Jun')
71 # $locale->text('Jul')
72 # $locale->text('Aug')
73 # $locale->text('Sep')
74 # $locale->text('Oct')
75 # $locale->text('Nov')
76 # $locale->text('Dec')
81 ########################################
82 # Eintrag fuer Version 2.2.0 geaendert #
83 # neue Optik im Rechnungsformular #
84 ########################################
86 $lxdebug->enter_sub();
88 if ($lizenzen && $form->{vc} eq "customer") {
89 if ($form->{type} =~ /sales_order/) {
90 @column_index = (runningnumber, partnumber, description, ship, qty);
91 } elsif ($form->{type} =~ /sales_quotation/) {
92 @column_index = (runningnumber, partnumber, description, qty);
94 @column_index = (runningnumber, partnumber, description, qty);
97 if ( ($form->{type} =~ /purchase_order/)
98 || ($form->{type} =~ /sales_order/)) {
99 @column_index = (runningnumber, partnumber, description, ship, qty);
101 @column_index = (runningnumber, partnumber, description, qty);
104 ############## ENDE Neueintrag ##################
106 my $dimension_units = AM->retrieve_units(\%myconfig, $form, "dimension");
107 my $service_units = AM->retrieve_units(\%myconfig, $form, "service");
108 my $all_units = AM->retrieve_units(\%myconfig, $form);
110 push @column_index, qw(unit);
112 #for pricegroups column
113 if ( $form->{type} =~ (/sales_quotation/)
114 or (($form->{level} =~ /Sales/) and ($form->{type} =~ /invoice/))
115 or (($form->{level} eq undef) and ($form->{type} =~ /invoice/))
116 or ($form->{type} =~ /sales_order/)) {
117 push @column_index, qw(sellprice_pg);
120 push @column_index, qw(sellprice);
122 if ($form->{vc} eq 'customer') {
123 push @column_index, qw(discount);
126 push @column_index, "linetotal";
128 my $colspan = $#column_index + 1;
130 $form->{invsubtotal} = 0;
131 map { $form->{"${_}_base"} = 0 } (split / /, $form->{taxaccounts});
133 ########################################
134 # Eintrag fuer Version 2.2.0 geaendert #
135 # neue Optik im Rechnungsformular #
136 ########################################
137 $column_data{runningnumber} =
138 qq|<th align=left nowrap width=5 class=listheading>|
139 . $locale->text('No.')
141 $column_data{partnumber} =
142 qq|<th align=left nowrap width=12 class=listheading>|
143 . $locale->text('Number')
145 $column_data{description} =
146 qq|<th align=left nowrap width=30 class=listheading>|
147 . $locale->text('Part Description')
150 qq|<th align=left nowrap width=5 class=listheading>|
151 . $locale->text('Ship')
154 qq|<th align=left nowrap width=5 class=listheading>|
155 . $locale->text('Qty')
158 qq|<th align=left nowrap width=5 class=listheading>|
159 . $locale->text('Unit')
161 $column_data{license} =
162 qq|<th align=left nowrap width=10 class=listheading>|
163 . $locale->text('License')
165 $column_data{serialnr} =
166 qq|<th align=left nowrap width=10 class=listheading>|
167 . $locale->text('Serial No.')
169 $column_data{projectnr} =
170 qq|<th align=left nowrap width=10 class=listheading>|
171 . $locale->text('Project')
173 $column_data{sellprice} =
174 qq|<th align=left nowrap width=15 class=listheading>|
175 . $locale->text('Price')
177 $column_data{sellprice_pg} =
178 qq|<th align=left nowrap width=15 class=listheading>|
179 . $locale->text('Pricegroup')
181 $column_data{discount} =
182 qq|<th align=left class=listheading>|
183 . $locale->text('Discount')
185 $column_data{linetotal} =
186 qq|<th align=left nowrap width=10 class=listheading>|
187 . $locale->text('Extended')
190 qq|<th align=left nowrap width=10 class=listheading>|
191 . $locale->text('Bin')
193 ############## ENDE Neueintrag ##################
199 <tr class=listheading>|;
201 map { print "\n$column_data{$_}" } @column_index;
207 $runningnumber = $locale->text('No.');
208 $deliverydate = $locale->text('Delivery Date');
209 $serialnumber = $locale->text('Serial No.');
210 $projectnumber = $locale->text('Project');
211 $partsgroup = $locale->text('Group');
212 $reqdate = $locale->text('Reqdate');
214 $delvar = 'deliverydate';
216 if ($form->{type} =~ /_order$/ || $form->{type} =~ /_quotation$/) {
217 $deliverydate = $locale->text('Required by');
221 for $i (1 .. $numrows) {
226 $form->parse_amount(\%myconfig, $form->{"${_}_$i"})
227 } qw(qty ship discount sellprice price_new price_old) unless ($form->{simple_save});
229 if (!$form->{"unit_old_$i"}) {
230 # Neue Ware aus der Datenbank. In diesem Fall ist unit_$i die
231 # Einheit, wie sie in den Stammdaten hinterlegt wurde.
232 # Es sollte also angenommen werden, dass diese ausgewaehlt war.
233 $form->{"unit_old_$i"} = $form->{"unit_$i"};
238 # Die zuletzt ausgewaehlte mit der aktuell ausgewaehlten Einheit
239 # vergleichen und bei Unterschied den Preis entsprechend umrechnen.
240 $form->{"selected_unit_$i"} = $form->{"unit_$i"} unless ($form->{"selected_unit_$i"});
242 my $check_units = $form->{"inventory_accno_$i"} ? $dimension_units : $service_units;
243 if (!$check_units->{$form->{"selected_unit_$i"}} ||
244 ($check_units->{$form->{"selected_unit_$i"}}->{"base_unit"} ne
245 $all_units->{$form->{"unit_old_$i"}}->{"base_unit"})) {
246 # Die ausgewaehlte Einheit ist fuer diesen Artikel nicht gueltig
247 # (z.B. Dimensionseinheit war ausgewaehlt, es handelt sich aber
248 # um eine Dienstleistung). Dann keinerlei Umrechnung vornehmen.
249 $form->{"unit_old_$i"} = $form->{"selected_unit_$i"} = $form->{"unit_$i"};
251 if ((!$form->{"prices_$i"}) || ($form->{"new_pricegroup_$i"} == $form->{"old_pricegroup_$i"})) {
252 if ($form->{"unit_old_$i"} ne $form->{"selected_unit_$i"}) {
254 if (defined($all_units->{$form->{"unit_old_$i"}}->{"factor"}) &&
255 $all_units->{$form->{"unit_old_$i"}}->{"factor"}) {
256 $basefactor = $all_units->{$form->{"selected_unit_$i"}}->{"factor"} /
257 $all_units->{$form->{"unit_old_$i"}}->{"factor"};
259 $form->{"sellprice_$i"} *= $basefactor;
260 $form->{"unit_old_$i"} = $form->{"selected_unit_$i"};
263 ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/);
265 $decimalplaces = ($dec > 2) ? $dec : 2;
269 $form->{"sellprice_$i"} * $form->{"discount_$i"} / 100,
273 $form->round_amount($form->{"sellprice_$i"} - $discount, $decimalplaces);
274 $linetotal = $form->round_amount($linetotal * $form->{"qty_$i"}, 2);
276 # convert " to "
277 map { $form->{"${_}_$i"} =~ s/\"/"/g }
278 qw(partnumber description unit unit_old);
280 ########################################
281 # Eintrag fuer Version 2.2.0 geaendert #
282 # neue Optik im Rechnungsformular #
283 ########################################
284 $column_data{runningnumber} =
285 qq|<td><input name="runningnumber_$i" size=5 value=$i></td>|; # HuT
286 ############## ENDE Neueintrag ##################
288 $column_data{partnumber} =
289 qq|<td><input name="partnumber_$i" size=12 value="$form->{"partnumber_$i"}"></td>|;
291 if (($rows = $form->numtextrows($form->{"description_$i"}, 30, 6)) > 1) {
292 $column_data{description} =
293 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>|;
295 $column_data{description} =
296 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>|;
299 (my $qty_dec) = ($form->{"qty_$i"} =~ /\.(\d+)/);
300 $qty_dec = length $qty_dec;
303 qq|<td align=right><input name="qty_$i" size=5 value=|
304 . $form->format_amount(\%myconfig, $form->{"qty_$i"}, $qty_dec) .qq|>|;
305 if ($form->{"formel_$i"}) {
306 $column_data{qty} .= qq|<button type="button" onclick="calculate_qty_selection_window('qty_$i','alu_$i', 'formel_$i', $i)">| . $locale->text('*/') . qq|</button>
307 <input type=hidden name="formel_$i" value="$form->{"formel_$i"}"><input type=hidden name="alu_$i" value="$form->{"alu_$i"}"></td>|;
310 qq|<td align=right><input name="ship_$i" size=5 value=|
311 . $form->format_amount(\%myconfig, $form->{"ship_$i"})
314 my $is_part = $form->{"inventory_accno_$i"};
315 my $is_assigned = $form->{"id_$i"};
316 my $this_unit = $form->{"unit_$i"};
317 if ($form->{"selected_unit_$i"} && $this_unit &&
318 $all_units->{$form->{"selected_unit_$i"}} && $all_units->{$this_unit} &&
319 ($all_units->{$form->{"selected_unit_$i"}}->{"base_unit"} eq $all_units->{$this_unit}->{"base_unit"})) {
320 $this_unit = $form->{"selected_unit_$i"};
321 } elsif (!$is_assigned ||
322 ($is_part && !$this_unit && ($all_units->{$this_unit} && ($all_units->{$this_unit}->{"base_unit"} eq $all_units->{"kg"}->{"base_unit"})))) {
326 $column_data{"unit"} = "<td>" .
327 ($qty_readonly ? " " :
328 AM->unit_select_html($is_part ? $dimension_units :
329 $is_assigned ? $service_units : $all_units,
330 "unit_$i", $this_unit,
331 $is_assigned ? $form->{"unit_$i"} : undef))
334 # build in drop down list for pricesgroups
335 if ($form->{"prices_$i"}) {
336 if ($form->{"new_pricegroup_$i"} != $form->{"old_pricegroup_$i"}) {
337 $price_tmp = $form->format_amount(\%myconfig, $form->{"price_new_$i"}, $decimalplaces);
339 $price_tmp = $form->format_amount(\%myconfig, $form->{"sellprice_$i"}, $decimalplaces);
342 $column_data{sellprice_pg} =
343 qq|<td align=right><select name="sellprice_pg_$i">$form->{"prices_$i"}</select></td>|;
344 $column_data{sellprice} =
345 qq|<td><input name="sellprice_$i" size=10 value=$price_tmp></td>|;
348 # for last row and report
349 # set pricegroup drop down list from report menu
350 if ($form->{"sellprice_$i"} != 0) {
352 qq|<option value="$form->{"sellprice_$i"}--$form->{"pricegroup_id_$i"}" selected>$form->{"pricegroup_$i"}</option>\n|;
354 $form->{"pricegroup_old_$i"} = $form->{"pricegroup_id_$i"};
356 $column_data{sellprice_pg} =
357 qq|<td align=right><select name="sellprice_pg_$i">$prices</select></td>|;
362 $column_data{sellprice_pg} = qq|<td align=right> </td>|;
365 $column_data{sellprice} =
366 qq|<td><input name="sellprice_$i" size=10 value=|
367 . $form->format_amount(\%myconfig, $form->{"sellprice_$i"},
371 $column_data{discount} =
372 qq|<td align=right><input name="discount_$i" size=3 value=|
373 . $form->format_amount(\%myconfig, $form->{"discount_$i"})
375 $column_data{linetotal} =
377 . $form->format_amount(\%myconfig, $linetotal, 2)
379 $column_data{bin} = qq|<td>$form->{"bin_$i"}</td>|;
381 ########################################
382 # Eintrag fuer Version 2.2.0 geaendert #
383 # neue Optik im Rechnungsformular #
384 ########################################
385 # if ($lizenzen && $form->{type} eq "invoice" && $form->{vc} eq "customer") {
386 # $column_data{license} = qq|<td><select name="licensenumber_$i">$form->{"lizenzen_$i"}></select></td>|;
389 # if ($form->{type} !~ /_quotation/) {
390 # $column_data{serialnr} = qq|<td><input name="serialnumber_$i" size=10 value="$form->{"serialnumber_$i"}"></td>|;
393 # $column_data{projectnr} = qq|<td><input name="projectnumber_$i" size=10 value="$form->{"projectnumber_$i"}"></td>|;
394 ############## ENDE Neueintrag ##################
398 <tr valign=top class=listrow$j>|;
400 map { print "\n$column_data{$_}" } @column_index;
405 <input type=hidden name="orderitems_id_$i" value=$form->{"orderitems_id_$i"}>
406 <input type=hidden name="bo_$i" value=$form->{"bo_$i"}>
408 <input type=hidden name="pricegroup_old_$i" value=$form->{"pricegroup_old_$i"}>
409 <input type=hidden name="price_old_$i" value=$form->{"price_old_$i"}>
410 <input type=hidden name="unit_old_$i" value="$form->{"selected_unit_$i"}">
411 <input type=hidden name="price_new_$i" value=|
412 . $form->format_amount(\%myconfig, $form->{"price_new_$i"}) . qq|>
414 <input type=hidden name="id_$i" value=$form->{"id_$i"}>
415 <input type=hidden name="inventory_accno_$i" value=$form->{"inventory_accno_$i"}>
416 <input type=hidden name="bin_$i" value="$form->{"bin_$i"}">
417 <input type=hidden name="partsgroup_$i" value="$form->{"partsgroup_$i"}">
418 <input type=hidden name="partnotes_$i" value="$form->{"partnotes_$i"}">
419 <input type=hidden name="income_accno_$i" value=$form->{"income_accno_$i"}>
420 <input type=hidden name="expense_accno_$i" value=$form->{"expense_accno_$i"}>
421 <input type=hidden name="listprice_$i" value="$form->{"listprice_$i"}">
422 <input type=hidden name="assembly_$i" value="$form->{"assembly_$i"}">
423 <input type=hidden name="taxaccounts_$i" value="$form->{"taxaccounts_$i"}">
424 <input type=hidden name="ordnumber_$i" value="$form->{"ordnumber_$i"}">
425 <input type=hidden name="transdate_$i" value="$form->{"transdate_$i"}">
426 <input type=hidden name="cusordnumber_$i" value="$form->{"cusordnumber_$i"}">
427 <input type=hidden name="longdescription_$i" value="$form->{"longdescription_$i"}">
428 <input type=hidden name="basefactor_$i" value="$form->{"basefactor_$i"}">
432 ########################################
433 # Eintrag fuer Version 2.2.0 geaendert #
434 # neue Optik im Rechnungsformular #
435 ########################################
439 <td colspan=$colspan>
441 if ($lizenzen && $form->{type} eq "invoice" && $form->{vc} eq "customer") {
442 my $selected = $form->{"licensenumber_$i"};
444 $form->{"lizenzen_$i"} =~ s/ selected//g;
445 $form->{"lizenzen_$i"} =~
446 s/value="${selected}"\>/value="${selected}" selected\>/;
447 $lizenzen_quoted = $form->{"lizenzen_$i"};
448 $lizenzen_quoted =~ s/\"/"/g;
450 <b>Lizenz\#</b> <select name="licensenumber_$i" size=1>
451 $form->{"lizenzen_$i"}
453 <input type=hidden name="lizenzen_$i" value="${lizenzen_quoted}">
456 if ($form->{type} !~ /_quotation/) {
458 <b>$serialnumber</b> <input name="serialnumber_$i" size=15 value="$form->{"serialnumber_$i"}">|;
462 <b>$projectnumber</b> <input name="projectnumber_$i" size=10 value="$form->{"projectnumber_$i"}">
463 <input type=hidden name="oldprojectnumber_$i" value="$form->{"oldprojectnumber_$i"}">
464 <input type=hidden name="project_id_$i" value="$form->{"project_id_$i"}">
466 if ($form->{type} eq 'invoice' or $form->{type} =~ /order/) {
468 ($form->{type} eq 'invoice')
470 : 'reqdate'; # invoice uses a different term for the same thing.
472 <b>${$reqdate_term}</b> <input name="${reqdate_term}_$i" size=11 value="$form->{"${reqdate_term}_$i"}">
475 my $subtotalchecked = ($form->{"subtotal_$i"}) ? "checked" : "";
477 <b>|.$locale->text('Subtotal').qq|</b> <input type="checkbox" name="subtotal_$i" value="1" "$subtotalchecked">
483 ############## ENDE Neueintrag ##################
485 map { $form->{"${_}_base"} += $linetotal }
486 (split / /, $form->{"taxaccounts_$i"});
488 $form->{invsubtotal} += $linetotal;
497 $lxdebug->leave_sub();
500 ##################################################
501 # build html-code for pricegroups in variable $form->{prices_$j}
504 $lxdebug->enter_sub();
505 my $rowcount = shift;
506 for $j (1 .. $rowcount) {
507 my $pricegroup_old = $form->{"pricegroup_old_$i"};
508 if ($form->{PRICES}{$j}) {
510 $prices = '<option value="--">' . $locale->text("none (pricegroup)") . '</option>';
512 foreach $item (@{ $form->{PRICES}{$j} }) {
514 #$price = $form->round_amount($myconfig, $item->{price}, 5);
515 #$price = $form->format_amount($myconfig, $item->{price}, 2);
516 $price = $item->{price};
517 $pricegroup_id = $item->{pricegroup_id};
518 $pricegroup = $item->{pricegroup};
520 # build drop down list for pricegroups
522 qq|<option value="$price--$pricegroup_id"$item->{selected}>$pricegroup</option>\n|;
527 # $form->{"${_}_$j"} =
528 # $form->format_amount(\%myconfig, $form->{"${_}_$j"})
529 # } qw(sellprice price_new price_old);
531 # set new selectedpricegroup_id and prices for "Preis"
532 if ($item->{selected} && ($pricegroup_id != 0)) {
533 $form->{"pricegroup_old_$j"} = $pricegroup_id;
534 $form->{"price_new_$j"} = $price;
535 $form->{"sellprice_$j"} = $price;
537 if ($pricegroup_id == 0) {
538 $form->{"price_new_$j"} = $form->{"sellprice_$j"};
541 $form->{"prices_$j"} = $prices;
544 $lxdebug->leave_sub();
548 $lxdebug->enter_sub();
549 @column_index = qw(ndx partnumber description onhand sellprice);
551 $column_data{ndx} = qq|<th> </th>|;
552 $column_data{partnumber} =
553 qq|<th class=listheading>| . $locale->text('Number') . qq|</th>|;
554 $column_data{description} =
555 qq|<th class=listheading>| . $locale->text('Part Description') . qq|</th>|;
556 $column_data{sellprice} =
557 qq|<th class=listheading>| . $locale->text('Price') . qq|</th>|;
558 $column_data{onhand} =
559 qq|<th class=listheading>| . $locale->text('Qty') . qq|</th>|;
561 # list items with radio button on a form
564 $title = $locale->text('Select from one of the items below');
565 $colspan = $#column_index + 1;
570 <form method=post action=$form->{script}>
574 <th class=listtop colspan=$colspan>$title</th>
577 <tr class=listheading>|;
579 map { print "\n$column_data{$_}" } @column_index;
584 foreach $ref (@{ $form->{item_list} }) {
585 $checked = ($i++) ? "" : "checked";
588 if ($ref->{inventory_accno} > 0) {
589 $ref->{"lizenzen"} = qq|<option></option>|;
590 foreach $item (@{ $form->{LIZENZEN}{ $ref->{"id"} } }) {
591 $ref->{"lizenzen"} .=
592 qq|<option value=\"$item->{"id"}\">$item->{"licensenumber"}</option>|;
594 $ref->{"lizenzen"} .= qq|<option value=-1>Neue Lizenz</option>|;
595 $ref->{"lizenzen"} =~ s/\"/"/g;
599 map { $ref->{$_} =~ s/\"/"/g } qw(partnumber description unit);
603 $form->round_amount($ref->{sellprice} * (1 - $form->{tradediscount}), 2);
605 qq|<td><input name=ndx class=radio type=radio value=$i $checked></td>|;
606 $column_data{partnumber} =
607 qq|<td><input name="new_partnumber_$i" type=hidden value="$ref->{partnumber}">$ref->{partnumber}</td>|;
608 $column_data{description} =
609 qq|<td><input name="new_description_$i" type=hidden value="$ref->{description}">$ref->{description}</td>|;
610 $column_data{sellprice} =
611 qq|<td align=right><input name="new_sellprice_$i" type=hidden value=$ref->{sellprice}>|
612 . $form->format_amount(\%myconfig, $ref->{sellprice}, 2, " ")
614 $column_data{onhand} =
615 qq|<td align=right><input name="new_onhand_$i" type=hidden value=$ref->{onhand}>|
616 . $form->format_amount(\%myconfig, $ref->{onhand}, '', " ")
622 <tr class=listrow$j>|;
624 map { print "\n$column_data{$_}" } @column_index;
629 <input name="new_bin_$i" type=hidden value="$ref->{bin}">
630 <input name="new_listprice_$i" type=hidden value=$ref->{listprice}>
631 <input name="new_inventory_accno_$i" type=hidden value=$ref->{inventory_accno}>
632 <input name="new_income_accno_$i" type=hidden value=$ref->{income_accno}>
633 <input name="new_expense_accno_$i" type=hidden value=$ref->{expense_accno}>
634 <input name="new_unit_$i" type=hidden value="$ref->{unit}">
635 <input name="new_weight_$i" type=hidden value="$ref->{weight}">
636 <input name="new_assembly_$i" type=hidden value="$ref->{assembly}">
637 <input name="new_taxaccounts_$i" type=hidden value="$ref->{taxaccounts}">
638 <input name="new_partsgroup_$i" type=hidden value="$ref->{partsgroup}">
639 <input name="new_formel_$i" type=hidden value="$ref->{formel}">
640 <input name="new_longdescription_$i" type=hidden value="$ref->{longdescription}">
641 <input name="new_not_discountable_$i" type=hidden value="$ref->{not_discountable}">
642 <input name="new_part_payment_id_$i" type=hidden value="$ref->{part_payment_id}">
644 <input name="new_id_$i" type=hidden value=$ref->{id}>
649 <input name="new_lizenzen_$i" type=hidden value="$ref->{lizenzen}">
656 <tr><td colspan=8><hr size=3 noshade></td></tr>
659 <input name=lastndx type=hidden value=$i>
663 # delete action variable
664 map { delete $form->{$_} } qw(action item_list header);
666 # save all other form variables
667 foreach $key (keys %${form}) {
668 $form->{$key} =~ s/\"/"/g;
669 print qq|<input name=$key type=hidden value="$form->{$key}">\n|;
673 <input type=hidden name=nextsub value=item_selected>
676 <input class=submit type=submit name=action value="|
677 . $locale->text('Continue') . qq|">
684 $lxdebug->leave_sub();
688 $lxdebug->enter_sub();
690 # replace the last row with the checked row
691 $i = $form->{rowcount};
692 $i = $form->{assembly_rows} if ($form->{item} eq 'assembly');
698 #($form->{"sellprice_$i"},$form->{"$pricegroup_old_$i"}) = split /--/, $form->{"sellprice_$i"};
699 #$form->{"sellprice_$i"} = $form->{"sellprice_$i"};
701 # if there was a price entered, override it
702 $sellprice = $form->parse_amount(\%myconfig, $form->{"sellprice_$i"});
704 map { $form->{"${_}_$i"} = $form->{"new_${_}_$j"} }
705 qw(id partnumber description sellprice listprice inventory_accno income_accno expense_accno bin unit weight assembly taxaccounts partsgroup formel longdescription not_discountable);
706 if ($form->{"part_payment_id_$i"} ne "") {
707 $form->{payment_id} = $form->{"part_payment_id_$i"};
711 map { $form->{"${_}_$i"} = $form->{"new_${_}_$j"} } qw(lizenzen);
714 ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/);
716 $decimalplaces = ($dec > 2) ? $dec : 2;
719 $form->{"sellprice_$i"} = $sellprice;
722 # if there is an exchange rate adjust sellprice
723 if (($form->{exchangerate} * 1) != 0) {
724 $form->{"sellprice_$i"} /= $form->{exchangerate};
725 $form->{"sellprice_$i"} =
726 $form->round_amount($form->{"sellprice_$i"}, $decimalplaces);
730 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
731 qw(sellprice listprice weight);
733 $form->{sellprice} += ($form->{"sellprice_$i"} * $form->{"qty_$i"});
734 $form->{weight} += ($form->{"weight_$i"} * $form->{"qty_$i"});
736 if ($form->{"not_discountable_$i"}) {
737 $form->{"discount_$i"} = 0;
741 $form->{"sellprice_$i"} * (1 - $form->{"discount_$i"} / 100) *
743 map { $form->{"${_}_base"} += $amount }
744 (split / /, $form->{"taxaccounts_$i"});
745 map { $amount += ($form->{"${_}_base"} * $form->{"${_}_rate"}) } split / /,
746 $form->{"taxaccounts_$i"}
747 if !$form->{taxincluded};
749 $form->{creditremaining} -= $amount;
751 $form->{"runningnumber_$i"} = $i;
753 # delete all the new_ variables
754 for $i (1 .. $form->{lastndx}) {
755 map { delete $form->{"new_${_}_$i"} }
756 qw(partnumber description sellprice bin listprice inventory_accno income_accno expense_accno unit assembly taxaccounts id);
759 map { delete $form->{$_} } qw(ndx lastndx nextsub);
764 $form->format_amount(\%myconfig, $form->{"${_}_$i"}, $decimalplaces)
765 } qw(sellprice listprice) if $form->{item} ne 'assembly';
767 # get pricegroups for parts
768 IS->get_pricegroups_for_parts(\%myconfig, \%$form);
770 # build up html code for prices_$i
771 set_pricegroup($form->{rowcount});
775 $lxdebug->leave_sub();
779 $lxdebug->enter_sub();
782 $form->{old_callback} = $form->escape($form->{callback}, 1);
783 $form->{callback} = $form->escape("$form->{script}?action=display_form", 1);
786 delete $form->{action};
788 # save all other form variables in a previousform variable
789 foreach $key (keys %$form) {
792 $form->{$key} =~ s/&/%26/g;
793 $previousform .= qq|$key=$form->{$key}&|;
796 $previousform = $form->escape($previousform, 1);
798 $i = $form->{rowcount};
799 map { $form->{"${_}_$i"} =~ s/\"/"/g } qw(partnumber description);
806 <h4 class=error>| . $locale->text('Item not on file!') . qq|
809 | . $locale->text('What type of item is this?') . qq|</h4>
811 <form method=post action=ic.pl>
815 <input class=radio type=radio name=item value=part checked> |
816 . $locale->text('Part') . qq|<br>
817 <input class=radio type=radio name=item value=service> |
818 . $locale->text('Service')
821 <input type=hidden name=previousform value="$previousform">
822 <input type=hidden name=partnumber value="$form->{"partnumber_$i"}">
823 <input type=hidden name=description value="$form->{"description_$i"}">
824 <input type=hidden name=rowcount value=$form->{rowcount}>
825 <input type=hidden name=taxaccount2 value=$form->{taxaccounts}>
826 <input type=hidden name=vc value=$form->{vc}>
828 <input type=hidden name=path value=$form->{path}>
829 <input type=hidden name=login value=$form->{login}>
830 <input type=hidden name=password value=$form->{password}>
832 <input type=hidden name=nextsub value=add>
835 <input class=submit type=submit name=action value="|
836 . $locale->text('Continue') . qq|">
843 $lxdebug->leave_sub();
847 $lxdebug->enter_sub();
851 $form->language_payment(\%myconfig);
853 # if we have a display_form
854 if ($form->{display_form}) {
855 &{"$form->{display_form}"};
859 # if ( $form->{print_and_post}
860 # && $form->{second_run}
861 # && ($form->{action} eq "display_form")) {
862 # for (keys %$form) { $old_form->{$_} = $form->{$_} }
863 # $old_form->{rowcount}++;
865 # #$form->{rowcount}--;
866 # #$form->{rowcount}--;
868 # $form->{print_and_post} = 0;
870 # &print_form($old_form);
874 # $form->{action} = "";
875 # $form->{resubmit} = 0;
877 # if ($form->{print_and_post} && !$form->{second_run}) {
878 # $form->{second_run} = 1;
879 # $form->{action} = "display_form";
880 # $form->{rowcount}--;
881 # my $rowcount = $form->{rowcount};
883 # # get pricegroups for parts
884 # IS->get_pricegroups_for_parts(\%myconfig, \%$form);
886 # # build up html code for prices_$i
887 # set_pricegroup($rowcount);
889 # $form->{resubmit} = 1;
894 $numrows = ++$form->{rowcount};
895 $subroutine = "display_row";
897 if ($form->{item} eq 'part') {
899 #set preisgruppenanzahl
900 $numrows = $form->{price_rows};
901 $subroutine = "price_row";
903 &{$subroutine}($numrows);
905 $numrows = ++$form->{makemodel_rows};
906 $subroutine = "makemodel_row";
908 if ($form->{item} eq 'assembly') {
909 $numrows = $form->{price_rows};
910 $subroutine = "price_row";
912 &{$subroutine}($numrows);
914 $numrows = ++$form->{makemodel_rows};
915 $subroutine = "makemodel_row";
917 # create makemodel rows
918 &{$subroutine}($numrows);
920 $numrows = ++$form->{assembly_rows};
921 $subroutine = "assembly_row";
923 if ($form->{item} eq 'service') {
924 $numrows = $form->{price_rows};
925 $subroutine = "price_row";
927 &{$subroutine}($numrows);
933 &{$subroutine}($numrows) if $numrows;
937 $lxdebug->leave_sub();
941 $lxdebug->enter_sub();
945 qw(id partnumber description qty ship sellprice unit discount inventory_accno income_accno expense_accno listprice taxaccounts bin assembly weight projectnumber project_id oldprojectnumber runningnumber serialnumber partsgroup payment_id not_discountable shop ve gv buchungsgruppen_id language_values sellprice_pg pricegroup_old price_old price_new unit_old ordnumber transdate longdescription basefactor)
949 # remove any makes or model rows
950 if ($form->{item} eq 'part') {
951 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
952 qw(listprice sellprice lastcost weight rop);
954 @flds = (make, model);
955 for my $i (1 .. ($form->{makemodel_rows})) {
956 if (($form->{"make_$i"} ne "") || ($form->{"model_$i"} ne "")) {
960 map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
965 $form->redo_rows(\@flds, \@a, $count, $form->{makemodel_rows});
966 $form->{makemodel_rows} = $count;
968 } elsif ($form->{item} eq 'assembly') {
970 $form->{sellprice} = 0;
972 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
973 qw(listprice rop stock);
976 qw(id qty unit bom partnumber description sellprice weight runningnumber partsgroup);
978 for my $i (1 .. ($form->{assembly_rows} - 1)) {
979 if ($form->{"qty_$i"}) {
983 $form->{"qty_$i"} = $form->parse_amount(\%myconfig, $form->{"qty_$i"});
985 map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
987 #($form->{"sellprice_$i"},$form->{"$pricegroup_old_$i"}) = split /--/, $form->{"sellprice_$i"};
989 $form->{sellprice} += ($form->{"qty_$i"} * $form->{"sellprice_$i"});
990 $form->{weight} += ($form->{"qty_$i"} * $form->{"weight_$i"});
995 $form->{sellprice} = $form->round_amount($form->{sellprice}, 2);
997 $form->redo_rows(\@flds, \@a, $count, $form->{assembly_rows});
998 $form->{assembly_rows} = $count;
1001 @flds = qw(make model);
1004 for my $i (1 .. ($form->{makemodel_rows})) {
1005 if (($form->{"make_$i"} ne "") || ($form->{"model_$i"} ne "")) {
1009 map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
1014 $form->redo_rows(\@flds, \@a, $count, $form->{makemodel_rows});
1015 $form->{makemodel_rows} = $count;
1019 # this section applies to invoices and orders
1020 # remove any empty numbers
1021 if ($form->{rowcount}) {
1022 for my $i (1 .. $form->{rowcount} - 1) {
1023 if ($form->{"partnumber_$i"}) {
1027 map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
1030 if ($form->{"licensenumber_$i"} == -1) {
1038 $form->redo_rows(\@flds, \@a, $count, $form->{rowcount});
1039 $form->{rowcount} = $count;
1041 $form->{creditremaining} -= &invoicetotal;
1048 if ( $form->{type} =~ (/sales_quotation/)
1049 or (($form->{level} =~ /Sales/) and ($form->{type} =~ /invoice/))
1050 or (($form->{level} eq undef) and ($form->{type} =~ /invoice/))
1051 or ($form->{type} =~ /sales_order/)) {
1053 # get pricegroups for parts
1054 IS->get_pricegroups_for_parts(\%myconfig, \%$form);
1056 # build up html code for prices_$i
1057 set_pricegroup($form->{rowcount});
1063 $lxdebug->leave_sub();
1067 $lxdebug->enter_sub();
1069 $form->{oldinvtotal} = 0;
1071 # add all parts and deduct paid
1072 map { $form->{"${_}_base"} = 0 } split / /, $form->{taxaccounts};
1074 my ($amount, $sellprice, $discount, $qty);
1076 for my $i (1 .. $form->{rowcount}) {
1077 $sellprice = $form->parse_amount(\%myconfig, $form->{"sellprice_$i"});
1078 $discount = $form->parse_amount(\%myconfig, $form->{"discount_$i"});
1079 $qty = $form->parse_amount(\%myconfig, $form->{"qty_$i"});
1081 #($form->{"sellprice_$i"}, $form->{"$pricegroup_old_$i"}) = split /--/, $form->{"sellprice_$i"};
1083 $amount = $sellprice * (1 - $discount / 100) * $qty;
1084 map { $form->{"${_}_base"} += $amount }
1085 (split / /, $form->{"taxaccounts_$i"});
1086 $form->{oldinvtotal} += $amount;
1089 map { $form->{oldinvtotal} += ($form->{"${_}_base"} * $form->{"${_}_rate"}) }
1090 split / /, $form->{taxaccounts}
1091 if !$form->{taxincluded};
1093 $form->{oldtotalpaid} = 0;
1094 for $i (1 .. $form->{paidaccounts}) {
1095 $form->{oldtotalpaid} += $form->{"paid_$i"};
1098 $lxdebug->leave_sub();
1101 return ($form->{oldinvtotal} - $form->{oldtotalpaid});
1104 sub validate_items {
1105 $lxdebug->enter_sub();
1107 # check if items are valid
1108 if ($form->{rowcount} == 1) {
1113 for $i (1 .. $form->{rowcount} - 1) {
1114 $form->isblank("partnumber_$i",
1115 $locale->text('Number missing in Row') . " $i");
1118 $lxdebug->leave_sub();
1122 $lxdebug->enter_sub();
1123 if ($form->{second_run}) {
1124 $form->{print_and_post} = 0;
1126 $form->{ordnumber} = $form->{invnumber};
1128 map { delete $form->{$_} } qw(id printed emailed queued);
1129 if ($form->{script} eq 'ir.pl' || $form->{type} eq 'request_quotation') {
1130 $form->{title} = $locale->text('Add Purchase Order');
1131 $form->{vc} = 'vendor';
1132 $form->{type} = 'purchase_order';
1135 if ($form->{script} eq 'is.pl' || $form->{type} eq 'sales_quotation') {
1136 $form->{title} = $locale->text('Add Sales Order');
1137 $form->{vc} = 'customer';
1138 $form->{type} = 'sales_order';
1141 $form->{script} = 'oe.pl';
1143 $form->{shipto} = 1;
1145 $form->{rowcount}--;
1147 $form->{cp_id} *= 1;
1149 require "$form->{path}/$form->{script}";
1151 map { $form->{"select$_"} = "" } ($form->{vc}, currency);
1153 $currency = $form->{currency};
1157 $form->{currency} = $currency;
1158 $form->{exchangerate} = "";
1159 $form->{forex} = "";
1160 $form->{exchangerate} = $exchangerate
1164 $form->check_exchangerate(
1165 \%myconfig, $form->{currency}, $form->{transdate}, $buysell
1171 $lxdebug->leave_sub();
1175 $lxdebug->enter_sub();
1176 if ($form->{second_run}) {
1177 $form->{print_and_post} = 0;
1179 map { delete $form->{$_} } qw(id printed emailed queued);
1181 if ($form->{script} eq 'ir.pl' || $form->{type} eq 'purchase_order') {
1182 $form->{title} = $locale->text('Add Request for Quotation');
1183 $form->{vc} = 'vendor';
1184 $form->{type} = 'request_quotation';
1187 if ($form->{script} eq 'is.pl' || $form->{type} eq 'sales_order') {
1188 $form->{title} = $locale->text('Add Quotation');
1189 $form->{vc} = 'customer';
1190 $form->{type} = 'sales_quotation';
1194 $form->{cp_id} *= 1;
1196 $form->{script} = 'oe.pl';
1198 $form->{shipto} = 1;
1200 $form->{rowcount}--;
1202 require "$form->{path}/$form->{script}";
1204 map { $form->{"select$_"} = "" } ($form->{vc}, currency);
1206 $currency = $form->{currency};
1210 $form->{currency} = $currency;
1211 $form->{exchangerate} = "";
1212 $form->{forex} = "";
1213 $form->{exchangerate} = $exchangerate
1217 $form->check_exchangerate(
1218 \%myconfig, $form->{currency}, $form->{transdate}, $buysell
1224 $lxdebug->leave_sub();
1228 $lxdebug->enter_sub();
1229 if ($form->{second_run}) {
1230 $form->{print_and_post} = 0;
1231 $form->{resubmit} = 0;
1233 if ($myconfig{role} eq 'admin') {
1235 <th align=right nowrap=true>| . $locale->text('Bcc') . qq|</th>
1236 <td><input name=bcc size=30 value="$form->{bcc}"></td>
1240 if ($form->{formname} =~ /(pick|packing|bin)_list/) {
1241 $form->{email} = $form->{shiptoemail} if $form->{shiptoemail};
1244 $name = $form->{ $form->{vc} };
1246 $title = $locale->text('E-mail') . " $name";
1248 $form->{oldmedia} = $form->{media};
1249 $form->{media} = "email";
1256 <form method=post action=$form->{script}>
1260 <th class=listtop>$title</th>
1262 <tr height="5"></tr>
1267 <th align=right nowrap>| . $locale->text('To') . qq|</th>
1268 <td><input name=email size=30 value="$form->{email}"></td>
1269 <th align=right nowrap>| . $locale->text('Cc') . qq|</th>
1270 <td><input name=cc size=30 value="$form->{cc}"></td>
1273 <th align=right nowrap>| . $locale->text('Subject') . qq|</th>
1274 <td><input name=subject size=30 value="$form->{subject}"></td>
1284 <th align=left nowrap>| . $locale->text('Message') . qq|</th>
1287 <td><textarea name=message rows=15 cols=60 wrap=soft>$form->{message}</textarea></td>
1298 map { delete $form->{$_} }
1299 qw(action email cc bcc subject message formname sendmode format header override);
1301 # save all other variables
1302 foreach $key (keys %$form) {
1303 $form->{$key} =~ s/\"/"/g;
1304 print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
1311 <td><hr size=3 noshade></td>
1315 <input type=hidden name=nextsub value=send_email>
1318 <input name=action class=submit type=submit value="|
1319 . $locale->text('Continue') . qq|">
1326 $lxdebug->leave_sub();
1330 $lxdebug->enter_sub();
1332 $old_form = new Form;
1334 map { $old_form->{$_} = $form->{$_} } keys %$form;
1335 $old_form->{media} = $form->{oldmedia};
1337 &print_form($old_form);
1339 $lxdebug->leave_sub();
1343 $lxdebug->enter_sub();
1344 $form->{sendmode} = "attachment";
1345 $form->{copies} = 3 unless $form->{copies};
1347 $form->{PD}{ $form->{formname} } = "selected";
1348 $form->{DF}{ $form->{format} } = "selected";
1349 $form->{OP}{ $form->{media} } = "selected";
1350 $form->{SM}{ $form->{sendmode} } = "selected";
1352 if ($form->{type} eq 'purchase_order') {
1353 $type = qq|<select name=formname>
1354 <option value=purchase_order $form->{PD}{purchase_order}>|
1355 . $locale->text('Purchase Order') . qq|
1356 <option value=bin_list $form->{PD}{bin_list}>|
1357 . $locale->text('Bin List');
1360 if ($form->{type} eq 'credit_note') {
1361 $type = qq|<select name=formname>
1362 <option value=credit_note $form->{PD}{credit_note}>|
1363 . $locale->text('Credit Note');
1366 if ($form->{type} eq 'sales_order') {
1367 $type = qq|<select name=formname>
1368 <option value=sales_order $form->{PD}{sales_order}>|
1369 . $locale->text('Confirmation') . qq|
1370 <option value=proforma $form->{PD}{proforma}>|
1371 . $locale->text('Proforma Invoice') . qq|
1372 <option value=pick_list $form->{PD}{pick_list}>|
1373 . $locale->text('Pick List') . qq|
1374 <option value=packing_list $form->{PD}{packing_list}>|
1375 . $locale->text('Packing List');
1378 if ($form->{type} =~ /_quotation$/) {
1379 $type = qq|<select name=formname>
1380 <option value="$`_quotation" $form->{PD}{"$`_quotation"}>|
1381 . $locale->text('Quotation');
1384 if ($form->{type} eq 'invoice') {
1385 $type = qq|<select name=formname>
1386 <option value=invoice $form->{PD}{invoice}>|
1387 . $locale->text('Invoice') . qq|
1388 <option value=proforma $form->{PD}{proforma}>|
1389 . $locale->text('Proforma Invoice') . qq|
1390 <option value=packing_list $form->{PD}{packing_list}>|
1391 . $locale->text('Packing List');
1394 if ($form->{type} eq 'invoice' && $form->{storno}) {
1395 $type = qq|<select name=formname>
1396 <option value=storno_invoice $form->{PD}{storno_invoice}>|
1397 . $locale->text('Storno Invoice') . qq|
1398 <option value=storno_packing_list $form->{PD}{storno_packing_list}>|
1399 . $locale->text('Storno Packing List');
1402 if ($form->{type} eq 'credit_note') {
1403 $type = qq|<select name=formname>
1404 <option value=credit_note $form->{PD}{credit_note}>|
1405 . $locale->text('Credit Note');
1408 if ($form->{type} eq 'ship_order') {
1409 $type = qq|<select name=formname>
1410 <option value=pick_list $form->{PD}{pick_list}>|
1411 . $locale->text('Pick List') . qq|
1412 <option value=packing_list $form->{PD}{packing_list}>|
1413 . $locale->text('Packing List');
1416 if ($form->{type} eq 'receive_order') {
1417 $type = qq|<select name=formname>
1418 <option value=bin_list $form->{PD}{bin_list}>|
1419 . $locale->text('Bin List');
1422 if ($form->{media} eq 'email') {
1423 $media = qq|<select name=sendmode>
1424 <option value=attachment $form->{SM}{attachment}>|
1425 . $locale->text('Attachment') . qq|
1426 <option value=inline $form->{SM}{inline}>| . $locale->text('In-line');
1428 $media = qq|<select name=media>
1429 <option value=screen $form->{OP}{screen}>| . $locale->text('Screen');
1430 if (scalar(keys (%{ $form->{printers} })) !=0 && $latex_templates) {
1432 <option value=printer $form->{OP}{printer}>|
1433 . $locale->text('Printer');
1435 if ($latex_templates) {
1437 <option value=queue $form->{OP}{queue}>| . $locale->text('Queue');
1441 $format = qq|<select name=format>|;
1442 if ($opendocument_templates && $openofficeorg_writer_bin &&
1443 $xvfb_bin && (-x $openofficeorg_writer_bin) && (-x $xvfb_bin)) {
1444 $format .= qq|<option value=opendocument_pdf | .
1445 $form->{DF}{"opendocument_pdf"} . qq|>| .
1446 $locale->text("PDF (OpenDocument/OASIS)") . qq|</option>|;
1449 if ($latex_templates) {
1450 $format .= qq|<option value=pdf $form->{DF}{pdf}>| .
1451 $locale->text('PDF') . qq|</option>|;
1454 $format .= qq|<option value=html $form->{DF}{html}>HTML</option>|;
1457 $format .= qq|<option value=postscript $form->{DF}{postscript}>| .
1458 $locale->text('Postscript') . qq|</option>|;
1461 if ($opendocument_templates) {
1462 $format .= qq|<option value=opendocument $form->{DF}{opendocument}>| .
1463 $locale->text("OpenDocument/OASIS") . qq|</option>|;
1465 $format .= qq|</select>|;
1467 if (scalar(keys (%{ $form->{languages} })) !=0) {
1468 $language_select = qq|<select name=language_id>
1469 <option value=""></option>}|;
1470 foreach $item (@{ $form->{languages} }) {
1471 if ($form->{language_id} eq $item->{id}) {
1472 $language_select .= qq|<option value="$item->{id}" selected>$item->{description}</option>|;
1474 $language_select .= qq|<option value="$item->{id}">$item->{description}</option>|;
1479 if (scalar(keys (%{ $form->{printers} })) !=0) {
1481 $printer_select = qq|<select name=printer_id>
1482 <option value=""></option>|;
1483 foreach $item (@{ $form->{printers} }) {
1484 $printer_select .= qq|<option value="$item->{id}">$item->{printer_description}</option>|;
1491 <table width=100% cellspacing=0 cellpadding=0>
1496 <td>$type</select></td>|;
1497 if (scalar(keys (%{ $form->{languages} })) !=0) {
1499 <td>${language_select}</select></td>|;
1502 <td>$format</select></td>
1503 <td>$media</select></td>|;
1504 if (scalar(keys (%{ $form->{printers} })) !=0) {
1506 <td>$printer_select</select></td>
1510 if (scalar(keys (%{ $form->{printers} })) !=0 && $latex_templates && $form->{media} ne 'email') {
1512 <td>| . $locale->text('Copies') . qq|
1513 <input name=copies size=2 value=$form->{copies}></td>
1517 $form->{groupitems} = "checked" if $form->{groupitems};
1520 <td>| . $locale->text('Group Items') . qq|</td>
1521 <td><input name=groupitems type=checkbox class=checkbox $form->{groupitems}></td>
1530 if ($form->{printed} =~ /$form->{formname}/) {
1532 <th>\|| . $locale->text('Printed') . qq|\|</th>
1536 if ($form->{emailed} =~ /$form->{formname}/) {
1538 <th>\|| . $locale->text('E-mailed') . qq|\|</th>
1542 if ($form->{queued} =~ /$form->{formname}/) {
1544 <th>\|| . $locale->text('Queued') . qq|\|</th>
1556 $lxdebug->leave_sub();
1560 $lxdebug->enter_sub();
1562 # if this goes to the printer pass through
1563 if ($form->{media} eq 'printer' || $form->{media} eq 'queue') {
1564 $form->error($locale->text('Select postscript or PDF!'))
1565 if ($form->{format} !~ /(postscript|pdf)/);
1567 $old_form = new Form;
1568 map { $old_form->{$_} = $form->{$_} } keys %$form;
1571 if (!$form->{id} || (($form->{formname} eq "proforma") && !$form->{proforma} && (($form->{type} =~ /_order$/) || ($form->{type} =~ /_quotation$/)))) {
1572 if ($form->{formname} eq "proforma") {
1573 $form->{proforma} = 1;
1575 $form->{print_and_save} = 1;
1576 my $formname = $form->{formname};
1578 $form->{formname} = $formname;
1583 &print_form($old_form);
1585 $lxdebug->leave_sub();
1589 $lxdebug->enter_sub();
1590 my ($old_form) = @_;
1594 $numberfld = "invnumber";
1597 ($form->{display_form}) ? $form->{display_form} : "display_form";
1599 # $form->{"notes"} will be overridden by the customer's/vendor's "notes" field. So save it here.
1600 $form->{ $form->{"formname"} . "notes" } = $form->{"notes"};
1602 if ($form->{formname} eq "invoice") {
1603 $form->{label} = $locale->text('Invoice');
1605 if ($form->{formname} eq "packing_list") {
1607 # this is from an invoice
1608 $form->{label} = $locale->text('Packing List');
1610 if ($form->{formname} eq 'sales_order') {
1613 $form->{"${inv}date"} = $form->{transdate};
1614 $form->{label} = $locale->text('Sales Order');
1615 $numberfld = "sonumber";
1619 if (($form->{type} eq 'invoice') && ($form->{formname} eq 'proforma') ) {
1622 $form->{"${inv}date"} = $form->{transdate};
1623 $form->{"invdate"} = $form->{transdate};
1624 $form->{label} = $locale->text('Proforma Invoice');
1625 $numberfld = "sonumber";
1629 if (($form->{type} eq 'sales_order') && ($form->{formname} eq 'proforma') ) {
1632 $form->{"${inv}date"} = $form->{transdate};
1633 $form->{"invdate"} = $form->{transdate};
1634 $form->{invnumber} = $form->{ordnumber};
1635 $form->{label} = $locale->text('Proforma Invoice');
1636 $numberfld = "sonumber";
1640 if ($form->{formname} eq 'packing_list' && $form->{type} ne 'invoice') {
1642 # we use the same packing list as from an invoice
1645 $form->{invdate} = $form->{"${inv}date"} = $form->{transdate};
1646 $form->{label} = $locale->text('Packing List');
1648 # set invnumber for template packing_list
1649 $form->{invnumber} = $form->{ordnumber};
1651 if ($form->{formname} eq 'pick_list') {
1654 $form->{"${inv}date"} =
1655 ($form->{transdate}) ? $form->{transdate} : $form->{invdate};
1656 $form->{label} = $locale->text('Pick List');
1657 $order = 1 unless $form->{type} eq 'invoice';
1659 if ($form->{formname} eq 'purchase_order') {
1662 $form->{"${inv}date"} = $form->{transdate};
1663 $form->{label} = $locale->text('Purchase Order');
1664 $numberfld = "ponumber";
1667 if ($form->{formname} eq 'bin_list') {
1670 $form->{"${inv}date"} = $form->{transdate};
1671 $form->{label} = $locale->text('Bin List');
1674 if ($form->{formname} eq 'sales_quotation') {
1677 $form->{"${inv}date"} = $form->{transdate};
1678 $form->{label} = $locale->text('Quotation');
1679 $numberfld = "sqnumber";
1683 if (($form->{type} eq 'sales_quotation') && ($form->{formname} eq 'proforma') ) {
1686 $form->{"${inv}date"} = $form->{transdate};
1687 $form->{"invdate"} = $form->{transdate};
1688 $form->{label} = $locale->text('Proforma Invoice');
1689 $numberfld = "sqnumber";
1693 if ($form->{formname} eq 'request_quotation') {
1696 $form->{"${inv}date"} = $form->{transdate};
1697 $form->{label} = $locale->text('Quotation');
1698 $numberfld = "rfqnumber";
1702 $form->isblank("email", $locale->text('E-mail address missing!'))
1703 if ($form->{media} eq 'email');
1704 $form->isblank("${inv}date",
1705 $locale->text($form->{label} . ' Date missing!'));
1707 # $locale->text('Invoice Number missing!')
1708 # $locale->text('Invoice Date missing!')
1709 # $locale->text('Packing List Number missing!')
1710 # $locale->text('Packing List Date missing!')
1711 # $locale->text('Order Number missing!')
1712 # $locale->text('Order Date missing!')
1713 # $locale->text('Quotation Number missing!')
1714 # $locale->text('Quotation Date missing!')
1717 if (!$form->{"${inv}number"} && !$form->{preview}) {
1718 $form->{"${inv}number"} = $form->update_defaults(\%myconfig, $numberfld);
1719 if ($form->{media} ne 'email') {
1721 # get pricegroups for parts
1722 IS->get_pricegroups_for_parts(\%myconfig, \%$form);
1724 # build up html code for prices_$i
1725 set_pricegroup($form->{rowcount});
1727 $form->{rowcount}--;
1736 # Save the email address given in the form because it should override the setting saved for the customer/vendor.
1737 my ($saved_email, $saved_cc, $saved_bcc) =
1738 ($form->{"email"}, $form->{"cc"}, $form->{"bcc"});
1740 $language_saved = $form->{language_id};
1741 $payment_id_saved = $form->{payment_id};
1743 &{"$form->{vc}_details"};
1745 $form->{language_id} = $language_saved;
1746 $form->{payment_id} = $payment_id_saved;
1748 $form->{"email"} = $saved_email if ($saved_email);
1749 $form->{"cc"} = $saved_cc if ($saved_cc);
1750 $form->{"bcc"} = $saved_bcc if ($saved_bcc);
1752 # format payment dates
1753 for $i (1 .. $form->{paidaccounts} - 1) {
1754 $form->{"datepaid_$i"} = $locale->date(\%myconfig, $form->{"datepaid_$i"});
1757 ($form->{employee}) = split /--/, $form->{employee};
1758 ($form->{warehouse}, $form->{warehouse_id}) = split /--/, $form->{warehouse};
1760 # create the form variables
1762 OE->order_details(\%myconfig, \%$form);
1764 IS->invoice_details(\%myconfig, \%$form, $locale);
1767 # format global dates
1768 map { $form->{$_} = $locale->date(\%myconfig, $form->{$_}, 1) }
1769 ("${inv}date", "${due}date", "shippingdate", "deliverydate");
1772 for my $field (qw(transdate_oe deliverydate_oe)) {
1774 $form->{$field}[$_] = $locale->date(\%myconfig, $form->{$field}[$_], 1);
1775 } 0 .. $#{ $form->{$field} };
1778 if ($form->{shipto_id}) {
1779 $form->get_shipto(\%myconfig);
1782 @a = qw(name street zipcode city country);
1786 # if there is no shipto fill it in from billto
1787 foreach $item (@a) {
1788 if ($form->{"shipto$item"}) {
1795 if ( $form->{formname} eq 'purchase_order'
1796 || $form->{formname} eq 'request_quotation') {
1797 $form->{shiptoname} = $myconfig{company};
1798 $form->{shiptostreet} = $myconfig{address};
1800 map { $form->{"shipto$_"} = $form->{$_} } @a;
1804 $form->{notes} =~ s/^\s+//g;
1806 map({ $form->{$_} =~ s/\\n/\n/g; } qw(company address));
1808 $form->{templates} = "$myconfig{templates}";
1810 $form->{language} = $form->get_template_language(\%myconfig);
1811 $form->{printer_code} = $form->get_printer_code(\%myconfig);
1813 if ($form->{language} ne "") {
1814 $form->{language} = "_" . $form->{language};
1817 if ($form->{printer_code} ne "") {
1818 $form->{printer_code} = "_" . $form->{printer_code};
1821 $form->{IN} = "$form->{formname}$form->{language}$form->{printer_code}.html";
1822 if ($form->{format} eq 'postscript') {
1823 $form->{postscript} = 1;
1824 $form->{IN} =~ s/html$/tex/;
1825 } elsif ($form->{"format"} =~ /pdf/) {
1827 if ($form->{"format"} =~ /opendocument/) {
1828 $form->{IN} =~ s/html$/odt/;
1830 $form->{IN} =~ s/html$/tex/;
1832 } elsif ($form->{"format"} =~ /opendocument/) {
1833 $form->{"opendocument"} = 1;
1834 $form->{"IN"} =~ s/html$/odt/;
1837 if ($form->{media} eq 'printer') {
1838 $form->{OUT} = "| $form->{printer_command} &>/dev/null";
1839 $form->{printed} .= " $form->{formname}";
1840 $form->{printed} =~ s/^ //;
1842 $printed = $form->{printed};
1844 if ($form->{media} eq 'email') {
1845 $form->{subject} = qq|$form->{label} $form->{"${inv}number"}|
1846 unless $form->{subject};
1848 $form->{OUT} = "$sendmail";
1850 $form->{emailed} .= " $form->{formname}";
1851 $form->{emailed} =~ s/^ //;
1853 $emailed = $form->{emailed};
1855 if ($form->{media} eq 'queue') {
1856 %queued = split / /, $form->{queued};
1858 if ($filename = $queued{ $form->{formname} }) {
1859 $form->{queued} =~ s/$form->{formname} $filename//;
1860 unlink "$spool/$filename";
1861 $filename =~ s/\..*$//g;
1867 $filename .= ($form->{postscript}) ? '.ps' : '.pdf';
1868 $form->{OUT} = ">$spool/$filename";
1871 $form->{queued} .= " $form->{formname} $filename";
1873 $form->{queued} =~ s/^ //;
1875 $queued = $form->{queued};
1877 $form->parse_template(\%myconfig, $userspath);
1879 $form->{callback} = "";
1881 if ($form->{media} eq 'email') {
1882 $form->{message} = $locale->text('sent') unless $form->{message};
1884 $message = $form->{message};
1886 # if we got back here restore the previous form
1887 if ($form->{media} =~ /(printer|email|queue)/) {
1889 $form->update_status(\%myconfig)
1890 if ($form->{media} eq 'queue' && $form->{id});
1894 $old_form->{"${inv}number"} = $form->{"${inv}number"};
1896 # restore and display form
1897 map { $form->{$_} = $old_form->{$_} } keys %$old_form;
1899 $form->{queued} = $queued;
1900 $form->{printed} = $printed;
1901 $form->{emailed} = $emailed;
1902 $form->{message} = $message;
1904 $form->{rowcount}--;
1905 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
1906 qw(exchangerate creditlimit creditremaining);
1908 for $i (1 .. $form->{paidaccounts}) {
1910 $form->{"${_}_$i"} =
1911 $form->parse_amount(\%myconfig, $form->{"${_}_$i"})
1912 } qw(paid exchangerate);
1920 ($form->{media} eq 'printer')
1921 ? $locale->text('sent to printer')
1922 : $locale->text('emailed to') . " $form->{email}";
1923 $form->redirect(qq|$form->{label} $form->{"${inv}number"} $msg|);
1925 if ($form->{printing}) {
1930 $lxdebug->leave_sub();
1933 sub customer_details {
1934 $lxdebug->enter_sub();
1935 IS->customer_details(\%myconfig, \%$form);
1936 $lxdebug->leave_sub();
1939 sub vendor_details {
1940 $lxdebug->enter_sub();
1942 IR->vendor_details(\%myconfig, \%$form);
1944 $lxdebug->leave_sub();
1948 $lxdebug->enter_sub();
1950 $form->{postasnew} = 1;
1951 map { delete $form->{$_} } qw(printed emailed queued);
1955 $lxdebug->leave_sub();
1959 $lxdebug->enter_sub();
1960 if ($form->{second_run}) {
1961 $form->{print_and_post} = 0;
1964 $title = $form->{title};
1965 $form->{title} = $locale->text('Ship to');
1967 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
1968 qw(exchangerate creditlimit creditremaining);
1970 # get details for name
1971 &{"$form->{vc}_details"};
1974 ($form->{vc} eq 'customer')
1975 ? $locale->text('Customer Number')
1976 : $locale->text('Vendor Number');
1978 # get pricegroups for parts
1979 IS->get_pricegroups_for_parts(\%myconfig, \%$form);
1981 # build up html code for prices_$i
1982 set_pricegroup($form->{rowcount});
1984 $nextsub = ($form->{display_form}) ? $form->{display_form} : "display_form";
1986 $form->{rowcount}--;
1993 <form method=post action=$form->{script}>
1999 <tr class=listheading>
2000 <th class=listheading colspan=2 width=50%>|
2001 . $locale->text('Billing Address') . qq|</th>
2002 <th class=listheading width=50%>|
2003 . $locale->text('Shipping Address') . qq|</th>
2005 <tr height="5"></tr>
2007 <th align=right nowrap>$number</th>
2008 <td>$form->{"$form->{vc}number"}</td>
2011 <th align=right nowrap>| . $locale->text('Company Name') . qq|</th>
2012 <td>$form->{name}</td>
2013 <td><input name=shiptoname size=35 value="$form->{shiptoname}"></td>
2016 <th align=right nowrap>| . $locale->text('Street') . qq|</th>
2017 <td>$form->{street}</td>
2018 <td><input name=shiptostreet size=35 value="$form->{shiptostreet}"></td>
2021 <th align=right nowrap>| . $locale->text('Zipcode') . qq|</th>
2022 <td>$form->{zipcode}</td>
2023 <td><input name=shiptozipcode size=35 value="$form->{shiptozipcode}"></td>
2026 <th align=right nowrap>| . $locale->text('City') . qq|</th>
2027 <td>$form->{city}</td>
2028 <td><input name=shiptocity size=35 value="$form->{shiptocity}"></td>
2031 <th align=right nowrap>| . $locale->text('Country') . qq|</th>
2032 <td>$form->{country}</td>
2033 <td><input name=shiptocountry size=35 value="$form->{shiptocountry}"></td>
2036 <th align=right nowrap>| . $locale->text('Contact') . qq|</th>
2037 <td>$form->{contact}</td>
2038 <td><input name=shiptocontact size=35 value="$form->{shiptocontact}"></td>
2041 <th align=right nowrap>| . $locale->text('Phone') . qq|</th>
2042 <td>$form->{"$form->{vc}phone"}</td>
2043 <td><input name=shiptophone size=20 value="$form->{shiptophone}"></td>
2046 <th align=right nowrap>| . $locale->text('Fax') . qq|</th>
2047 <td>$form->{"$form->{vc}fax"}</td>
2048 <td><input name=shiptofax size=20 value="$form->{shiptofax}"></td>
2051 <th align=right nowrap>| . $locale->text('E-mail') . qq|</th>
2052 <td>$form->{email}</td>
2053 <td><input name=shiptoemail size=35 value="$form->{shiptoemail}"></td>
2060 <input type=hidden name=nextsub value=$nextsub>
2064 map { delete $form->{$_} }
2065 qw(shiptoname shiptostreet shiptozipcode shiptocity shiptocountry shiptocontact shiptophone shiptofax shiptoemail header);
2066 $form->{title} = $title;
2068 foreach $key (keys %$form) {
2069 $form->{$key} =~ s/\"/"/g;
2070 print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
2078 <input class=submit type=submit name=action value="|
2079 . $locale->text('Continue') . qq|">
2086 $lxdebug->leave_sub();
2090 $lxdebug->enter_sub();
2095 $form->{old_callback} = $form->escape($form->{callback}, 1);
2096 $form->{callback} = $form->escape("$form->{script}?action=display_form", 1);
2097 $form->{old_callback} = $form->escape($form->{old_callback}, 1);
2100 delete $form->{action};
2101 $customer = $form->{customer};
2102 map { $form->{"old_$_"} = $form->{"${_}_$row"} } qw(partnumber description);
2104 # save all other form variables in a previousform variable
2105 $form->{row} = $row;
2106 foreach $key (keys %$form) {
2109 $form->{$key} =~ s/&/%26/g;
2110 $previousform .= qq|$key=$form->{$key}&|;
2113 $previousform = $form->escape($previousform, 1);
2115 $form->{script} = "licenses.pl";
2117 map { $form->{$_} = $form->{"old_$_"} } qw(partnumber description);
2118 map { $form->{$_} = $form->escape($form->{$_}, 1) }
2119 qw(partnumber description);
2121 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|;
2124 $lxdebug->leave_sub();
2127 sub relink_accounts {
2128 $lxdebug->enter_sub();
2130 $form->{"taxaccounts"} =~ s/\s*$//;
2131 $form->{"taxaccounts"} =~ s/^\s*//;
2132 foreach my $accno (split(/\s*/, $form->{"taxaccounts"})) {
2133 map({ delete($form->{"${accno}_${_}"}); } qw(rate description taxnumber));
2135 $form->{"taxaccounts"} = "";
2137 for ($i = 1; $i <= $form->{"rowcount"}; $i++) {
2138 if ($form->{"id_$i"}) {
2139 IC->retrieve_taxaccounts(\%myconfig, $form, $form->{"id_$i"}, $i, 1);
2143 $lxdebug->leave_sub();