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"}">
427 <input type=hidden name="adr_description_$i" value="$form->{"adr_description_$i"}">
431 ########################################
432 # Eintrag fuer Version 2.2.0 geaendert #
433 # neue Optik im Rechnungsformular #
434 ########################################
438 <td colspan=$colspan>
440 if ($lizenzen && $form->{type} eq "invoice" && $form->{vc} eq "customer") {
441 my $selected = $form->{"licensenumber_$i"};
443 $form->{"lizenzen_$i"} =~ s/ selected//g;
444 $form->{"lizenzen_$i"} =~
445 s/value="${selected}"\>/value="${selected}" selected\>/;
446 $lizenzen_quoted = $form->{"lizenzen_$i"};
447 $lizenzen_quoted =~ s/\"/"/g;
449 <b>Lizenz\#</b> <select name="licensenumber_$i" size=1>
450 $form->{"lizenzen_$i"}
452 <input type=hidden name="lizenzen_$i" value="${lizenzen_quoted}">
455 if ($form->{type} !~ /_quotation/) {
457 <b>$serialnumber</b> <input name="serialnumber_$i" size=15 value="$form->{"serialnumber_$i"}">|;
461 <b>$projectnumber</b> <input name="projectnumber_$i" size=10 value="$form->{"projectnumber_$i"}">
462 <input type=hidden name="oldprojectnumber_$i" value="$form->{"oldprojectnumber_$i"}">
463 <input type=hidden name="project_id_$i" value="$form->{"project_id_$i"}">
465 if ($form->{type} eq 'invoice' or $form->{type} =~ /order/) {
467 ($form->{type} eq 'invoice')
469 : 'reqdate'; # invoice uses a different term for the same thing.
471 <b>${$reqdate_term}</b> <input name="${reqdate_term}_$i" size=11 value="$form->{"${reqdate_term}_$i"}">
474 my $subtotalchecked = ($form->{"subtotal_$i"}) ? "checked" : "";
476 <b>|.$locale->text('Subtotal').qq|</b> <input type="checkbox" name="subtotal_$i" value="1" "$subtotalchecked">
482 ############## ENDE Neueintrag ##################
484 map { $form->{"${_}_base"} += $linetotal }
485 (split / /, $form->{"taxaccounts_$i"});
487 $form->{invsubtotal} += $linetotal;
496 $lxdebug->leave_sub();
499 ##################################################
500 # build html-code for pricegroups in variable $form->{prices_$j}
503 $lxdebug->enter_sub();
504 my $rowcount = shift;
505 for $j (1 .. $rowcount) {
506 my $pricegroup_old = $form->{"pricegroup_old_$i"};
507 if ($form->{PRICES}{$j}) {
509 $prices = '<option value="--">' . $locale->text("none (pricegroup)") . '</option>';
511 foreach $item (@{ $form->{PRICES}{$j} }) {
513 #$price = $form->round_amount($myconfig, $item->{price}, 5);
514 #$price = $form->format_amount($myconfig, $item->{price}, 2);
515 $price = $item->{price};
516 $pricegroup_id = $item->{pricegroup_id};
517 $pricegroup = $item->{pricegroup};
519 # build drop down list for pricegroups
521 qq|<option value="$price--$pricegroup_id"$item->{selected}>$pricegroup</option>\n|;
526 # $form->{"${_}_$j"} =
527 # $form->format_amount(\%myconfig, $form->{"${_}_$j"})
528 # } qw(sellprice price_new price_old);
530 # set new selectedpricegroup_id and prices for "Preis"
531 if ($item->{selected} && ($pricegroup_id != 0)) {
532 $form->{"pricegroup_old_$j"} = $pricegroup_id;
533 $form->{"price_new_$j"} = $price;
534 $form->{"sellprice_$j"} = $price;
536 if ($pricegroup_id == 0) {
537 $form->{"price_new_$j"} = $form->{"sellprice_$j"};
540 $form->{"prices_$j"} = $prices;
543 $lxdebug->leave_sub();
547 $lxdebug->enter_sub();
548 @column_index = qw(ndx partnumber description onhand sellprice);
550 $column_data{ndx} = qq|<th> </th>|;
551 $column_data{partnumber} =
552 qq|<th class=listheading>| . $locale->text('Number') . qq|</th>|;
553 $column_data{description} =
554 qq|<th class=listheading>| . $locale->text('Part Description') . qq|</th>|;
555 $column_data{sellprice} =
556 qq|<th class=listheading>| . $locale->text('Price') . qq|</th>|;
557 $column_data{onhand} =
558 qq|<th class=listheading>| . $locale->text('Qty') . qq|</th>|;
560 # list items with radio button on a form
563 $title = $locale->text('Select from one of the items below');
564 $colspan = $#column_index + 1;
569 <form method=post action=$form->{script}>
573 <th class=listtop colspan=$colspan>$title</th>
576 <tr class=listheading>|;
578 map { print "\n$column_data{$_}" } @column_index;
583 foreach $ref (@{ $form->{item_list} }) {
584 $checked = ($i++) ? "" : "checked";
587 if ($ref->{inventory_accno} > 0) {
588 $ref->{"lizenzen"} = qq|<option></option>|;
589 foreach $item (@{ $form->{LIZENZEN}{ $ref->{"id"} } }) {
590 $ref->{"lizenzen"} .=
591 qq|<option value=\"$item->{"id"}\">$item->{"licensenumber"}</option>|;
593 $ref->{"lizenzen"} .= qq|<option value=-1>Neue Lizenz</option>|;
594 $ref->{"lizenzen"} =~ s/\"/"/g;
598 map { $ref->{$_} =~ s/\"/"/g } qw(partnumber description unit);
602 $form->round_amount($ref->{sellprice} * (1 - $form->{tradediscount}), 2);
604 qq|<td><input name=ndx class=radio type=radio value=$i $checked></td>|;
605 $column_data{partnumber} =
606 qq|<td><input name="new_partnumber_$i" type=hidden value="$ref->{partnumber}">$ref->{partnumber}</td>|;
607 $column_data{description} =
608 qq|<td><input name="new_description_$i" type=hidden value="$ref->{description}">$ref->{description}</td>|;
609 $column_data{sellprice} =
610 qq|<td align=right><input name="new_sellprice_$i" type=hidden value=$ref->{sellprice}>|
611 . $form->format_amount(\%myconfig, $ref->{sellprice}, 2, " ")
613 $column_data{onhand} =
614 qq|<td align=right><input name="new_onhand_$i" type=hidden value=$ref->{onhand}>|
615 . $form->format_amount(\%myconfig, $ref->{onhand}, '', " ")
621 <tr class=listrow$j>|;
623 map { print "\n$column_data{$_}" } @column_index;
628 <input name="new_bin_$i" type=hidden value="$ref->{bin}">
629 <input name="new_listprice_$i" type=hidden value=$ref->{listprice}>
630 <input name="new_inventory_accno_$i" type=hidden value=$ref->{inventory_accno}>
631 <input name="new_income_accno_$i" type=hidden value=$ref->{income_accno}>
632 <input name="new_expense_accno_$i" type=hidden value=$ref->{expense_accno}>
633 <input name="new_unit_$i" type=hidden value="$ref->{unit}">
634 <input name="new_weight_$i" type=hidden value="$ref->{weight}">
635 <input name="new_assembly_$i" type=hidden value="$ref->{assembly}">
636 <input name="new_taxaccounts_$i" type=hidden value="$ref->{taxaccounts}">
637 <input name="new_partsgroup_$i" type=hidden value="$ref->{partsgroup}">
638 <input name="new_formel_$i" type=hidden value="$ref->{formel}">
639 <input name="new_alu_$i" type=hidden value="$ref->{alu}">
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}">
643 <input name="new_adr_description_$i" type=hidden value="$ref->{adr_description}">
645 <input name="new_id_$i" type=hidden value=$ref->{id}>
650 <input name="new_lizenzen_$i" type=hidden value="$ref->{lizenzen}">
657 <tr><td colspan=8><hr size=3 noshade></td></tr>
660 <input name=lastndx type=hidden value=$i>
664 # delete action variable
665 map { delete $form->{$_} } qw(action item_list header);
667 # save all other form variables
668 foreach $key (keys %${form}) {
669 $form->{$key} =~ s/\"/"/g;
670 print qq|<input name=$key type=hidden value="$form->{$key}">\n|;
674 <input type=hidden name=nextsub value=item_selected>
677 <input class=submit type=submit name=action value="|
678 . $locale->text('Continue') . qq|">
685 $lxdebug->leave_sub();
689 $lxdebug->enter_sub();
691 # replace the last row with the checked row
692 $i = $form->{rowcount};
693 $i = $form->{assembly_rows} if ($form->{item} eq 'assembly');
699 #($form->{"sellprice_$i"},$form->{"$pricegroup_old_$i"}) = split /--/, $form->{"sellprice_$i"};
700 #$form->{"sellprice_$i"} = $form->{"sellprice_$i"};
702 # if there was a price entered, override it
703 $sellprice = $form->parse_amount(\%myconfig, $form->{"sellprice_$i"});
705 map { $form->{"${_}_$i"} = $form->{"new_${_}_$j"} }
706 qw(id partnumber description sellprice listprice inventory_accno income_accno expense_accno bin unit weight assembly taxaccounts partsgroup formel alu longdescription not_discountable adr_description);
707 if ($form->{"part_payment_id_$i"} ne "") {
708 $form->{payment_id} = $form->{"part_payment_id_$i"};
712 map { $form->{"${_}_$i"} = $form->{"new_${_}_$j"} } qw(lizenzen);
715 ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/);
717 $decimalplaces = ($dec > 2) ? $dec : 2;
720 $form->{"sellprice_$i"} = $sellprice;
723 # if there is an exchange rate adjust sellprice
724 if (($form->{exchangerate} * 1) != 0) {
725 $form->{"sellprice_$i"} /= $form->{exchangerate};
726 $form->{"sellprice_$i"} =
727 $form->round_amount($form->{"sellprice_$i"}, $decimalplaces);
731 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
732 qw(sellprice listprice weight);
734 $form->{sellprice} += ($form->{"sellprice_$i"} * $form->{"qty_$i"});
735 $form->{weight} += ($form->{"weight_$i"} * $form->{"qty_$i"});
737 if ($form->{"not_discountable_$i"}) {
738 $form->{"discount_$i"} = 0;
742 $form->{"sellprice_$i"} * (1 - $form->{"discount_$i"} / 100) *
744 map { $form->{"${_}_base"} += $amount }
745 (split / /, $form->{"taxaccounts_$i"});
746 map { $amount += ($form->{"${_}_base"} * $form->{"${_}_rate"}) } split / /,
747 $form->{"taxaccounts_$i"}
748 if !$form->{taxincluded};
750 $form->{creditremaining} -= $amount;
752 $form->{"runningnumber_$i"} = $i;
754 # delete all the new_ variables
755 for $i (1 .. $form->{lastndx}) {
756 map { delete $form->{"new_${_}_$i"} }
757 qw(partnumber description sellprice bin listprice inventory_accno income_accno expense_accno unit assembly taxaccounts id);
760 map { delete $form->{$_} } qw(ndx lastndx nextsub);
765 $form->format_amount(\%myconfig, $form->{"${_}_$i"}, $decimalplaces)
766 } qw(sellprice listprice) if $form->{item} ne 'assembly';
768 # get pricegroups for parts
769 IS->get_pricegroups_for_parts(\%myconfig, \%$form);
771 # build up html code for prices_$i
772 set_pricegroup($form->{rowcount});
776 $lxdebug->leave_sub();
780 $lxdebug->enter_sub();
783 $form->{old_callback} = $form->escape($form->{callback}, 1);
784 $form->{callback} = $form->escape("$form->{script}?action=display_form", 1);
787 delete $form->{action};
789 # save all other form variables in a previousform variable
790 foreach $key (keys %$form) {
793 $form->{$key} =~ s/&/%26/g;
794 $previousform .= qq|$key=$form->{$key}&|;
797 $previousform = $form->escape($previousform, 1);
799 $i = $form->{rowcount};
800 map { $form->{"${_}_$i"} =~ s/\"/"/g } qw(partnumber description);
807 <h4 class=error>| . $locale->text('Item not on file!') . qq|
810 | . $locale->text('What type of item is this?') . qq|</h4>
812 <form method=post action=ic.pl>
816 <input class=radio type=radio name=item value=part checked> |
817 . $locale->text('Part') . qq|<br>
818 <input class=radio type=radio name=item value=service> |
819 . $locale->text('Service')
822 <input type=hidden name=previousform value="$previousform">
823 <input type=hidden name=partnumber value="$form->{"partnumber_$i"}">
824 <input type=hidden name=description value="$form->{"description_$i"}">
825 <input type=hidden name=rowcount value=$form->{rowcount}>
826 <input type=hidden name=taxaccount2 value=$form->{taxaccounts}>
827 <input type=hidden name=vc value=$form->{vc}>
829 <input type=hidden name=path value=$form->{path}>
830 <input type=hidden name=login value=$form->{login}>
831 <input type=hidden name=password value=$form->{password}>
833 <input type=hidden name=nextsub value=add>
836 <input class=submit type=submit name=action value="|
837 . $locale->text('Continue') . qq|">
844 $lxdebug->leave_sub();
848 $lxdebug->enter_sub();
849 $form->language_payment(\%myconfig);
851 # if we have a display_form
852 if ($form->{display_form}) {
853 &{"$form->{display_form}"};
857 # if ( $form->{print_and_post}
858 # && $form->{second_run}
859 # && ($form->{action} eq "display_form")) {
860 # for (keys %$form) { $old_form->{$_} = $form->{$_} }
861 # $old_form->{rowcount}++;
863 # #$form->{rowcount}--;
864 # #$form->{rowcount}--;
866 # $form->{print_and_post} = 0;
868 # &print_form($old_form);
872 # $form->{action} = "";
873 # $form->{resubmit} = 0;
875 # if ($form->{print_and_post} && !$form->{second_run}) {
876 # $form->{second_run} = 1;
877 # $form->{action} = "display_form";
878 # $form->{rowcount}--;
879 # my $rowcount = $form->{rowcount};
881 # # get pricegroups for parts
882 # IS->get_pricegroups_for_parts(\%myconfig, \%$form);
884 # # build up html code for prices_$i
885 # set_pricegroup($rowcount);
887 # $form->{resubmit} = 1;
892 $numrows = ++$form->{rowcount};
893 $subroutine = "display_row";
895 if ($form->{item} eq 'part') {
897 #set preisgruppenanzahl
898 $numrows = $form->{price_rows};
899 $subroutine = "price_row";
901 &{$subroutine}($numrows);
903 $numrows = ++$form->{makemodel_rows};
904 $subroutine = "makemodel_row";
906 if ($form->{item} eq 'assembly') {
907 $numrows = $form->{price_rows};
908 $subroutine = "price_row";
910 &{$subroutine}($numrows);
912 $numrows = ++$form->{makemodel_rows};
913 $subroutine = "makemodel_row";
915 # create makemodel rows
916 &{$subroutine}($numrows);
918 $numrows = ++$form->{assembly_rows};
919 $subroutine = "assembly_row";
921 if ($form->{item} eq 'service') {
922 $numrows = $form->{price_rows};
923 $subroutine = "price_row";
925 &{$subroutine}($numrows);
931 &{$subroutine}($numrows) if $numrows;
935 $lxdebug->leave_sub();
939 $lxdebug->enter_sub();
943 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 adr_id language_values)
947 # remove any makes or model rows
948 if ($form->{item} eq 'part') {
949 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
950 qw(listprice sellprice lastcost weight rop);
952 @flds = (make, model);
953 for my $i (1 .. ($form->{makemodel_rows})) {
954 if (($form->{"make_$i"} ne "") || ($form->{"model_$i"} ne "")) {
958 map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
963 $form->redo_rows(\@flds, \@a, $count, $form->{makemodel_rows});
964 $form->{makemodel_rows} = $count;
966 } elsif ($form->{item} eq 'assembly') {
968 $form->{sellprice} = 0;
970 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
971 qw(listprice rop stock);
974 qw(id qty unit bom partnumber description sellprice weight runningnumber partsgroup);
976 for my $i (1 .. ($form->{assembly_rows} - 1)) {
977 if ($form->{"qty_$i"}) {
981 $form->{"qty_$i"} = $form->parse_amount(\%myconfig, $form->{"qty_$i"});
983 map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
985 #($form->{"sellprice_$i"},$form->{"$pricegroup_old_$i"}) = split /--/, $form->{"sellprice_$i"};
987 $form->{sellprice} += ($form->{"qty_$i"} * $form->{"sellprice_$i"});
988 $form->{weight} += ($form->{"qty_$i"} * $form->{"weight_$i"});
993 $form->{sellprice} = $form->round_amount($form->{sellprice}, 2);
995 $form->redo_rows(\@flds, \@a, $count, $form->{assembly_rows});
996 $form->{assembly_rows} = $count;
999 @flds = qw(make model);
1002 for my $i (1 .. ($form->{makemodel_rows})) {
1003 if (($form->{"make_$i"} ne "") || ($form->{"model_$i"} ne "")) {
1007 map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
1012 $form->redo_rows(\@flds, \@a, $count, $form->{makemodel_rows});
1013 $form->{makemodel_rows} = $count;
1017 # this section applies to invoices and orders
1018 # remove any empty numbers
1019 if ($form->{rowcount}) {
1020 for my $i (1 .. $form->{rowcount} - 1) {
1021 if ($form->{"partnumber_$i"}) {
1025 map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
1028 if ($form->{"licensenumber_$i"} == -1) {
1036 $form->redo_rows(\@flds, \@a, $count, $form->{rowcount});
1037 $form->{rowcount} = $count;
1039 $form->{creditremaining} -= &invoicetotal;
1046 if ( $form->{type} =~ (/sales_quotation/)
1047 or (($form->{level} =~ /Sales/) and ($form->{type} =~ /invoice/))
1048 or (($form->{level} eq undef) and ($form->{type} =~ /invoice/))
1049 or ($form->{type} =~ /sales_order/)) {
1051 # get pricegroups for parts
1052 IS->get_pricegroups_for_parts(\%myconfig, \%$form);
1054 # build up html code for prices_$i
1055 set_pricegroup($form->{rowcount});
1061 $lxdebug->leave_sub();
1065 $lxdebug->enter_sub();
1067 $form->{oldinvtotal} = 0;
1069 # add all parts and deduct paid
1070 map { $form->{"${_}_base"} = 0 } split / /, $form->{taxaccounts};
1072 my ($amount, $sellprice, $discount, $qty);
1074 for my $i (1 .. $form->{rowcount}) {
1075 $sellprice = $form->parse_amount(\%myconfig, $form->{"sellprice_$i"});
1076 $discount = $form->parse_amount(\%myconfig, $form->{"discount_$i"});
1077 $qty = $form->parse_amount(\%myconfig, $form->{"qty_$i"});
1079 #($form->{"sellprice_$i"}, $form->{"$pricegroup_old_$i"}) = split /--/, $form->{"sellprice_$i"};
1081 $amount = $sellprice * (1 - $discount / 100) * $qty;
1082 map { $form->{"${_}_base"} += $amount }
1083 (split / /, $form->{"taxaccounts_$i"});
1084 $form->{oldinvtotal} += $amount;
1087 map { $form->{oldinvtotal} += ($form->{"${_}_base"} * $form->{"${_}_rate"}) }
1088 split / /, $form->{taxaccounts}
1089 if !$form->{taxincluded};
1091 $form->{oldtotalpaid} = 0;
1092 for $i (1 .. $form->{paidaccounts}) {
1093 $form->{oldtotalpaid} += $form->{"paid_$i"};
1096 $lxdebug->leave_sub();
1099 return ($form->{oldinvtotal} - $form->{oldtotalpaid});
1102 sub validate_items {
1103 $lxdebug->enter_sub();
1105 # check if items are valid
1106 if ($form->{rowcount} == 1) {
1111 for $i (1 .. $form->{rowcount} - 1) {
1112 $form->isblank("partnumber_$i",
1113 $locale->text('Number missing in Row') . " $i");
1116 $lxdebug->leave_sub();
1120 $lxdebug->enter_sub();
1121 if ($form->{second_run}) {
1122 $form->{print_and_post} = 0;
1124 $form->{ordnumber} = $form->{invnumber};
1126 map { delete $form->{$_} } qw(id printed emailed queued);
1127 if ($form->{script} eq 'ir.pl' || $form->{type} eq 'request_quotation') {
1128 $form->{title} = $locale->text('Add Purchase Order');
1129 $form->{vc} = 'vendor';
1130 $form->{type} = 'purchase_order';
1133 if ($form->{script} eq 'is.pl' || $form->{type} eq 'sales_quotation') {
1134 $form->{title} = $locale->text('Add Sales Order');
1135 $form->{vc} = 'customer';
1136 $form->{type} = 'sales_order';
1139 $form->{script} = 'oe.pl';
1141 $form->{shipto} = 1;
1143 $form->{rowcount}--;
1145 $form->{cp_id} *= 1;
1147 require "$form->{path}/$form->{script}";
1149 map { $form->{"select$_"} = "" } ($form->{vc}, currency);
1151 $currency = $form->{currency};
1155 $form->{currency} = $currency;
1156 $form->{exchangerate} = "";
1157 $form->{forex} = "";
1158 $form->{exchangerate} = $exchangerate
1162 $form->check_exchangerate(
1163 \%myconfig, $form->{currency}, $form->{transdate}, $buysell
1169 $lxdebug->leave_sub();
1173 $lxdebug->enter_sub();
1174 if ($form->{second_run}) {
1175 $form->{print_and_post} = 0;
1177 map { delete $form->{$_} } qw(id printed emailed queued);
1179 if ($form->{script} eq 'ir.pl' || $form->{type} eq 'purchase_order') {
1180 $form->{title} = $locale->text('Add Request for Quotation');
1181 $form->{vc} = 'vendor';
1182 $form->{type} = 'request_quotation';
1185 if ($form->{script} eq 'is.pl' || $form->{type} eq 'sales_order') {
1186 $form->{title} = $locale->text('Add Quotation');
1187 $form->{vc} = 'customer';
1188 $form->{type} = 'sales_quotation';
1192 $form->{cp_id} *= 1;
1194 $form->{script} = 'oe.pl';
1196 $form->{shipto} = 1;
1198 $form->{rowcount}--;
1200 require "$form->{path}/$form->{script}";
1202 map { $form->{"select$_"} = "" } ($form->{vc}, currency);
1204 $currency = $form->{currency};
1208 $form->{currency} = $currency;
1209 $form->{exchangerate} = "";
1210 $form->{forex} = "";
1211 $form->{exchangerate} = $exchangerate
1215 $form->check_exchangerate(
1216 \%myconfig, $form->{currency}, $form->{transdate}, $buysell
1222 $lxdebug->leave_sub();
1226 $lxdebug->enter_sub();
1227 if ($form->{second_run}) {
1228 $form->{print_and_post} = 0;
1229 $form->{resubmit} = 0;
1231 if ($myconfig{role} eq 'admin') {
1233 <th align=right nowrap=true>| . $locale->text('Bcc') . qq|</th>
1234 <td><input name=bcc size=30 value="$form->{bcc}"></td>
1238 if ($form->{formname} =~ /(pick|packing|bin)_list/) {
1239 $form->{email} = $form->{shiptoemail} if $form->{shiptoemail};
1242 $name = $form->{ $form->{vc} };
1244 $title = $locale->text('E-mail') . " $name";
1246 $form->{oldmedia} = $form->{media};
1247 $form->{media} = "email";
1254 <form method=post action=$form->{script}>
1258 <th class=listtop>$title</th>
1260 <tr height="5"></tr>
1265 <th align=right nowrap>| . $locale->text('To') . qq|</th>
1266 <td><input name=email size=30 value="$form->{email}"></td>
1267 <th align=right nowrap>| . $locale->text('Cc') . qq|</th>
1268 <td><input name=cc size=30 value="$form->{cc}"></td>
1271 <th align=right nowrap>| . $locale->text('Subject') . qq|</th>
1272 <td><input name=subject size=30 value="$form->{subject}"></td>
1282 <th align=left nowrap>| . $locale->text('Message') . qq|</th>
1285 <td><textarea name=message rows=15 cols=60 wrap=soft>$form->{message}</textarea></td>
1296 map { delete $form->{$_} }
1297 qw(action email cc bcc subject message formname sendmode format header override);
1299 # save all other variables
1300 foreach $key (keys %$form) {
1301 $form->{$key} =~ s/\"/"/g;
1302 print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
1309 <td><hr size=3 noshade></td>
1313 <input type=hidden name=nextsub value=send_email>
1316 <input name=action class=submit type=submit value="|
1317 . $locale->text('Continue') . qq|">
1324 $lxdebug->leave_sub();
1328 $lxdebug->enter_sub();
1330 $old_form = new Form;
1332 map { $old_form->{$_} = $form->{$_} } keys %$form;
1333 $old_form->{media} = $form->{oldmedia};
1335 &print_form($old_form);
1337 $lxdebug->leave_sub();
1341 $lxdebug->enter_sub();
1342 $form->{sendmode} = "attachment";
1343 $form->{copies} = 3 unless $form->{copies};
1345 $form->{PD}{ $form->{formname} } = "selected";
1346 $form->{DF}{ $form->{format} } = "selected";
1347 $form->{OP}{ $form->{media} } = "selected";
1348 $form->{SM}{ $form->{sendmode} } = "selected";
1350 if ($form->{type} eq 'purchase_order') {
1351 $type = qq|<select name=formname>
1352 <option value=purchase_order $form->{PD}{purchase_order}>|
1353 . $locale->text('Purchase Order') . qq|
1354 <option value=bin_list $form->{PD}{bin_list}>|
1355 . $locale->text('Bin List');
1358 if ($form->{type} eq 'credit_note') {
1359 $type = qq|<select name=formname>
1360 <option value=credit_note $form->{PD}{credit_note}>|
1361 . $locale->text('Credit Note');
1364 if ($form->{type} eq 'sales_order') {
1365 $type = qq|<select name=formname>
1366 <option value=sales_order $form->{PD}{sales_order}>|
1367 . $locale->text('Confirmation') . qq|
1368 <option value=proforma $form->{PD}{proforma}>|
1369 . $locale->text('Proforma Invoice') . qq|
1370 <option value=pick_list $form->{PD}{pick_list}>|
1371 . $locale->text('Pick List') . qq|
1372 <option value=packing_list $form->{PD}{packing_list}>|
1373 . $locale->text('Packing List') . qq|
1374 <option value=agb $form->{PD}{agb}>|
1375 . $locale->text('AGB') . qq|
1376 <option value=bunker_receipt $form->{PD}{bunker_receipt}>|
1377 . $locale->text('Bunker Receipt');
1380 if ($form->{type} =~ /_quotation$/) {
1381 $type = qq|<select name=formname>
1382 <option value="$`_quotation" $form->{PD}{"$`_quotation"}>|
1383 . $locale->text('Quotation')
1387 if ($form->{type} eq 'invoice') {
1388 $type = qq|<select name=formname>
1389 <option value=invoice $form->{PD}{invoice}>|
1390 . $locale->text('Invoice') . qq|
1391 <option value=proforma $form->{PD}{proforma}>|
1392 . $locale->text('Proforma Invoice') . qq|
1393 <option value=packing_list $form->{PD}{packing_list}>|
1394 . $locale->text('Packing List');
1397 if ($form->{type} eq 'invoice' && $form->{storno}) {
1398 $type = qq|<select name=formname>
1399 <option value=storno_invoice $form->{PD}{storno_invoice}>|
1400 . $locale->text('Storno Invoice') . qq|
1401 <option value=storno_packing_list $form->{PD}{storno_packing_list}>|
1402 . $locale->text('Storno Packing List');
1405 if ($form->{type} eq 'credit_note') {
1406 $type = qq|<select name=formname>
1407 <option value=credit_note $form->{PD}{credit_note}>|
1408 . $locale->text('Credit Note');
1411 if ($form->{type} eq 'ship_order') {
1412 $type = qq|<select name=formname>
1413 <option value=pick_list $form->{PD}{pick_list}>|
1414 . $locale->text('Pick List') . qq|
1415 <option value=packing_list $form->{PD}{packing_list}>|
1416 . $locale->text('Packing List');
1419 if ($form->{type} eq 'receive_order') {
1420 $type = qq|<select name=formname>
1421 <option value=bin_list $form->{PD}{bin_list}>|
1422 . $locale->text('Bin List');
1425 if ($form->{media} eq 'email') {
1426 $media = qq|<select name=sendmode>
1427 <option value=attachment $form->{SM}{attachment}>|
1428 . $locale->text('Attachment') . qq|
1429 <option value=inline $form->{SM}{inline}>| . $locale->text('In-line');
1431 $media = qq|<select name=media>
1432 <option value=screen $form->{OP}{screen}>| . $locale->text('Screen');
1433 if (scalar(keys (%{ $form->{printers} })) !=0 && $latex_templates) {
1435 <option value=printer $form->{OP}{printer}>|
1436 . $locale->text('Printer');
1438 if ($latex_templates) {
1440 <option value=queue $form->{OP}{queue}>| . $locale->text('Queue');
1444 $format = qq|<select name=format>|;
1445 if ($opendocument_templates && $openofficeorg_writer_bin &&
1446 $xvfb_bin && (-x $openofficeorg_writer_bin) && (-x $xvfb_bin)) {
1447 $format .= qq|<option value=opendocument_pdf | .
1448 $form->{DF}{"opendocument_pdf"} . qq|>| .
1449 $locale->text("PDF (OpenDocument/OASIS)") . qq|</option>|;
1452 if ($latex_templates) {
1453 $format .= qq|<option value=pdf $form->{DF}{pdf}>| .
1454 $locale->text('PDF') . qq|</option>|;
1457 $format .= qq|<option value=html $form->{DF}{html}>HTML</option>|;
1460 $format .= qq|<option value=postscript $form->{DF}{postscript}>| .
1461 $locale->text('Postscript') . qq|</option>|;
1464 if ($opendocument_templates) {
1465 $format .= qq|<option value=opendocument $form->{DF}{opendocument}>| .
1466 $locale->text("OpenDocument/OASIS") . qq|</option>|;
1468 $format .= qq|</select>|;
1470 if (scalar(keys (%{ $form->{languages} })) !=0) {
1472 $language_select = qq|<select name=language_id>|;
1473 foreach $item (@{ $form->{languages} }) {
1474 if ($form->{language_id} eq $item->{id}) {
1475 $language_select .= qq|<option value="$item->{id}" selected>$item->{description}</option>|;
1477 $language_select .= qq|<option value="$item->{id}">$item->{description}</option>|;
1482 if (scalar(keys (%{ $form->{printers} })) !=0) {
1484 $printer_select = qq|<select name=printer_id>
1485 <option value=""></option>|;
1486 foreach $item (@{ $form->{printers} }) {
1487 $printer_select .= qq|<option value="$item->{id}">$item->{printer_description}</option>|;
1494 <table width=100% cellspacing=0 cellpadding=0>
1499 <td>$type</select></td>|;
1500 if (scalar(keys (%{ $form->{languages} })) !=0) {
1502 <td>${language_select}</select></td>|;
1505 <td>$format</select></td>
1506 <td>$media</select></td>|;
1507 if (scalar(keys (%{ $form->{printers} })) !=0) {
1509 <td>$printer_select</select></td>
1513 if (scalar(keys (%{ $form->{printers} })) !=0 && $latex_templates && $form->{media} ne 'email') {
1515 <td>| . $locale->text('Copies') . qq|
1516 <input name=copies size=2 value=$form->{copies}></td>
1520 $form->{groupitems} = "checked" if $form->{groupitems};
1523 <td>| . $locale->text('Group Items') . qq|</td>
1524 <td><input name=groupitems type=checkbox class=checkbox $form->{groupitems}></td>
1533 if ($form->{printed} =~ /$form->{formname}/) {
1535 <th>\|| . $locale->text('Printed') . qq|\|</th>
1539 if ($form->{emailed} =~ /$form->{formname}/) {
1541 <th>\|| . $locale->text('E-mailed') . qq|\|</th>
1545 if ($form->{queued} =~ /$form->{formname}/) {
1547 <th>\|| . $locale->text('Queued') . qq|\|</th>
1559 $lxdebug->leave_sub();
1563 $lxdebug->enter_sub();
1565 # if this goes to the printer pass through
1566 if ($form->{media} eq 'printer' || $form->{media} eq 'queue') {
1567 $form->error($locale->text('Select postscript or PDF!'))
1568 if ($form->{format} !~ /(postscript|pdf)/);
1570 $old_form = new Form;
1571 map { $old_form->{$_} = $form->{$_} } keys %$form;
1574 if (!$form->{id} || (($form->{formname} eq "proforma") && !$form->{proforma} && (($form->{type} =~ /_order$/) || ($form->{type} =~ /_quotation$/)))) {
1575 if ($form->{formname} eq "proforma") {
1576 $form->{proforma} = 1;
1578 $form->{print_and_save} = 1;
1579 my $formname = $form->{formname};
1581 $form->{formname} = $formname;
1586 &print_form($old_form);
1588 $lxdebug->leave_sub();
1592 $lxdebug->enter_sub();
1593 my ($old_form) = @_;
1597 $numberfld = "invnumber";
1600 ($form->{display_form}) ? $form->{display_form} : "display_form";
1602 # $form->{"notes"} will be overridden by the customer's/vendor's "notes" field. So save it here.
1603 $form->{ $form->{"formname"} . "notes" } = $form->{"notes"};
1605 if ($form->{formname} eq "invoice") {
1606 $form->{label} = $locale->text('Invoice');
1608 if ($form->{formname} eq "packing_list") {
1610 # this is from an invoice
1611 $form->{label} = $locale->text('Packing List');
1613 if (($form->{formname} eq 'sales_order') || ($form->{formname} eq 'agb') || ($form->{formname} eq 'bunker_receipt')) {
1616 $form->{"${inv}date"} = $form->{transdate};
1617 $form->{label} = $locale->text('Sales Order');
1618 $numberfld = "sonumber";
1622 if (($form->{type} eq 'invoice') && ($form->{formname} eq 'proforma') ) {
1625 $form->{"${inv}date"} = $form->{transdate};
1626 $form->{"invdate"} = $form->{transdate};
1627 $form->{label} = $locale->text('Proforma Invoice');
1628 $numberfld = "sonumber";
1632 if (($form->{type} eq 'sales_order') && ($form->{formname} eq 'proforma') ) {
1635 $form->{"${inv}date"} = $form->{transdate};
1636 $form->{"invdate"} = $form->{transdate};
1637 $form->{invnumber} = $form->{ordnumber};
1638 $form->{label} = $locale->text('Proforma Invoice');
1639 $numberfld = "sonumber";
1643 if ($form->{formname} eq 'packing_list' && $form->{type} ne 'invoice') {
1645 # we use the same packing list as from an invoice
1648 $form->{invdate} = $form->{"${inv}date"} = $form->{transdate};
1649 $form->{label} = $locale->text('Packing List');
1651 # set invnumber for template packing_list
1652 $form->{invnumber} = $form->{ordnumber};
1654 if ($form->{formname} eq 'pick_list') {
1657 $form->{"${inv}date"} =
1658 ($form->{transdate}) ? $form->{transdate} : $form->{invdate};
1659 $form->{label} = $locale->text('Pick List');
1660 $order = 1 unless $form->{type} eq 'invoice';
1662 if ($form->{formname} eq 'purchase_order') {
1665 $form->{"${inv}date"} = $form->{transdate};
1666 $form->{label} = $locale->text('Purchase Order');
1667 $numberfld = "ponumber";
1670 if ($form->{formname} eq 'bin_list') {
1673 $form->{"${inv}date"} = $form->{transdate};
1674 $form->{label} = $locale->text('Bin List');
1677 if ($form->{formname} eq 'sales_quotation') {
1680 $form->{"${inv}date"} = $form->{transdate};
1681 $form->{label} = $locale->text('Quotation');
1682 $numberfld = "sqnumber";
1686 if (($form->{type} eq 'sales_quotation') && ($form->{formname} eq 'proforma') ) {
1689 $form->{"${inv}date"} = $form->{transdate};
1690 $form->{"invdate"} = $form->{transdate};
1691 $form->{label} = $locale->text('Proforma Invoice');
1692 $numberfld = "sqnumber";
1696 if ($form->{formname} eq 'request_quotation') {
1699 $form->{"${inv}date"} = $form->{transdate};
1700 $form->{label} = $locale->text('Quotation');
1701 $numberfld = "rfqnumber";
1705 $form->isblank("email", $locale->text('E-mail address missing!'))
1706 if ($form->{media} eq 'email');
1707 $form->isblank("${inv}date",
1708 $locale->text($form->{label} . ' Date missing!'));
1710 # $locale->text('Invoice Number missing!')
1711 # $locale->text('Invoice Date missing!')
1712 # $locale->text('Packing List Number missing!')
1713 # $locale->text('Packing List Date missing!')
1714 # $locale->text('Order Number missing!')
1715 # $locale->text('Order Date missing!')
1716 # $locale->text('Quotation Number missing!')
1717 # $locale->text('Quotation Date missing!')
1720 if (!$form->{"${inv}number"} && !$form->{preview}) {
1721 $form->{"${inv}number"} = $form->update_defaults(\%myconfig, $numberfld);
1722 if ($form->{media} ne 'email') {
1724 # get pricegroups for parts
1725 IS->get_pricegroups_for_parts(\%myconfig, \%$form);
1727 # build up html code for prices_$i
1728 set_pricegroup($form->{rowcount});
1730 $form->{rowcount}--;
1739 # Save the email address given in the form because it should override the setting saved for the customer/vendor.
1740 my ($saved_email, $saved_cc, $saved_bcc) =
1741 ($form->{"email"}, $form->{"cc"}, $form->{"bcc"});
1743 $language_saved = $form->{language_id};
1744 &{"$form->{vc}_details"};
1745 $form->{language_id} = $language_saved;
1747 $form->{"email"} = $saved_email if ($saved_email);
1748 $form->{"cc"} = $saved_cc if ($saved_cc);
1749 $form->{"bcc"} = $saved_bcc if ($saved_bcc);
1751 # format payment dates
1752 for $i (1 .. $form->{paidaccounts} - 1) {
1753 $form->{"datepaid_$i"} = $locale->date(\%myconfig, $form->{"datepaid_$i"});
1756 ($form->{employee}) = split /--/, $form->{employee};
1757 ($form->{warehouse}, $form->{warehouse_id}) = split /--/, $form->{warehouse};
1759 # create the form variables
1761 OE->order_details(\%myconfig, \%$form);
1763 IS->invoice_details(\%myconfig, \%$form, $locale);
1766 # format global dates
1767 map { $form->{$_} = $locale->date(\%myconfig, $form->{$_}, 1) }
1768 ("${inv}date", "${due}date", "shippingdate", "deliverydate");
1771 for my $field (qw(transdate_oe deliverydate_oe)) {
1773 $form->{$field}[$_] = $locale->date(\%myconfig, $form->{$field}[$_], 1);
1774 } 0 .. $#{ $form->{$field} };
1777 if ($form->{shipto_id}) {
1778 $form->get_shipto(\%myconfig);
1781 @a = qw(name street zipcode city country);
1785 # if there is no shipto fill it in from billto
1786 foreach $item (@a) {
1787 if ($form->{"shipto$item"}) {
1794 if ( $form->{formname} eq 'purchase_order'
1795 || $form->{formname} eq 'request_quotation') {
1796 $form->{shiptoname} = $myconfig{company};
1797 $form->{shiptostreet} = $myconfig{address};
1799 map { $form->{"shipto$_"} = $form->{$_} } @a;
1803 $form->{notes} =~ s/^\s+//g;
1805 map({ $form->{$_} =~ s/\\n/\n/g; } qw(company address));
1807 $form->{templates} = "$myconfig{templates}";
1809 $form->{language} = $form->get_template_language(\%myconfig);
1810 $form->{printer_code} = $form->get_printer_code(\%myconfig);
1812 if ($form->{language} ne "") {
1813 $form->{language} = "_" . $form->{language};
1816 if ($form->{printer_code} ne "") {
1817 $form->{printer_code} = "_" . $form->{printer_code};
1820 $form->{IN} = "$form->{formname}$form->{language}$form->{printer_code}.html";
1821 if ($form->{format} eq 'postscript') {
1822 $form->{postscript} = 1;
1823 $form->{IN} =~ s/html$/tex/;
1824 } elsif ($form->{"format"} =~ /pdf/) {
1826 if ($form->{"format"} =~ /opendocument/) {
1827 $form->{IN} =~ s/html$/odt/;
1829 $form->{IN} =~ s/html$/tex/;
1831 } elsif ($form->{"format"} =~ /opendocument/) {
1832 $form->{"opendocument"} = 1;
1833 $form->{"IN"} =~ s/html$/odt/;
1836 if ($form->{media} eq 'printer') {
1837 $form->{OUT} = "| $form->{printer_command} &>/dev/null";
1838 $form->{printed} .= " $form->{formname}";
1839 $form->{printed} =~ s/^ //;
1841 $printed = $form->{printed};
1843 if ($form->{media} eq 'email') {
1844 $form->{subject} = qq|$form->{label} $form->{"${inv}number"}|
1845 unless $form->{subject};
1847 $form->{OUT} = "$sendmail";
1849 $form->{emailed} .= " $form->{formname}";
1850 $form->{emailed} =~ s/^ //;
1852 $emailed = $form->{emailed};
1854 if ($form->{media} eq 'queue') {
1855 %queued = split / /, $form->{queued};
1857 if ($filename = $queued{ $form->{formname} }) {
1858 $form->{queued} =~ s/$form->{formname} $filename//;
1859 unlink "$spool/$filename";
1860 $filename =~ s/\..*$//g;
1866 $filename .= ($form->{postscript}) ? '.ps' : '.pdf';
1867 $form->{OUT} = ">$spool/$filename";
1870 $form->{queued} .= " $form->{formname} $filename";
1872 $form->{queued} =~ s/^ //;
1874 $queued = $form->{queued};
1876 $form->parse_template(\%myconfig, $userspath);
1878 $form->{callback} = "";
1880 if ($form->{media} eq 'email') {
1881 $form->{message} = $locale->text('sent') unless $form->{message};
1883 $message = $form->{message};
1885 # if we got back here restore the previous form
1886 if ($form->{media} =~ /(printer|email|queue)/) {
1888 $form->update_status(\%myconfig)
1889 if ($form->{media} eq 'queue' && $form->{id});
1893 $old_form->{"${inv}number"} = $form->{"${inv}number"};
1895 # restore and display form
1896 map { $form->{$_} = $old_form->{$_} } keys %$old_form;
1898 $form->{queued} = $queued;
1899 $form->{printed} = $printed;
1900 $form->{emailed} = $emailed;
1901 $form->{message} = $message;
1903 $form->{rowcount}--;
1904 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
1905 qw(exchangerate creditlimit creditremaining);
1907 for $i (1 .. $form->{paidaccounts}) {
1909 $form->{"${_}_$i"} =
1910 $form->parse_amount(\%myconfig, $form->{"${_}_$i"})
1911 } qw(paid exchangerate);
1919 ($form->{media} eq 'printer')
1920 ? $locale->text('sent to printer')
1921 : $locale->text('emailed to') . " $form->{email}";
1922 $form->redirect(qq|$form->{label} $form->{"${inv}number"} $msg|);
1924 if ($form->{printing}) {
1929 $lxdebug->leave_sub();
1932 sub customer_details {
1933 $lxdebug->enter_sub();
1934 IS->customer_details(\%myconfig, \%$form);
1935 $lxdebug->leave_sub();
1938 sub vendor_details {
1939 $lxdebug->enter_sub();
1941 IR->vendor_details(\%myconfig, \%$form);
1943 $lxdebug->leave_sub();
1947 $lxdebug->enter_sub();
1949 $form->{postasnew} = 1;
1950 map { delete $form->{$_} } qw(printed emailed queued);
1954 $lxdebug->leave_sub();
1958 $lxdebug->enter_sub();
1959 if ($form->{second_run}) {
1960 $form->{print_and_post} = 0;
1963 $title = $form->{title};
1964 $form->{title} = $locale->text('Ship to');
1966 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
1967 qw(exchangerate creditlimit creditremaining);
1969 # get details for name
1970 &{"$form->{vc}_details"};
1973 ($form->{vc} eq 'customer')
1974 ? $locale->text('Customer Number')
1975 : $locale->text('Vendor Number');
1977 # get pricegroups for parts
1978 IS->get_pricegroups_for_parts(\%myconfig, \%$form);
1980 # build up html code for prices_$i
1981 set_pricegroup($form->{rowcount});
1983 $nextsub = ($form->{display_form}) ? $form->{display_form} : "display_form";
1985 $form->{rowcount}--;
1992 <form method=post action=$form->{script}>
1998 <tr class=listheading>
1999 <th class=listheading colspan=2 width=50%>|
2000 . $locale->text('Billing Address') . qq|</th>
2001 <th class=listheading width=50%>|
2002 . $locale->text('Shipping Address') . qq|</th>
2004 <tr height="5"></tr>
2006 <th align=right nowrap>$number</th>
2007 <td>$form->{"$form->{vc}number"}</td>
2010 <th align=right nowrap>| . $locale->text('Company Name') . qq|</th>
2011 <td>$form->{name}</td>
2012 <td><input name=shiptoname size=35 value="$form->{shiptoname}"></td>
2015 <th align=right nowrap>| . $locale->text('Street') . qq|</th>
2016 <td>$form->{street}</td>
2017 <td><input name=shiptostreet size=35 value="$form->{shiptostreet}"></td>
2020 <th align=right nowrap>| . $locale->text('Zipcode') . qq|</th>
2021 <td>$form->{zipcode}</td>
2022 <td><input name=shiptozipcode size=35 value="$form->{shiptozipcode}"></td>
2025 <th align=right nowrap>| . $locale->text('City') . qq|</th>
2026 <td>$form->{city}</td>
2027 <td><input name=shiptocity size=35 value="$form->{shiptocity}"></td>
2030 <th align=right nowrap>| . $locale->text('Country') . qq|</th>
2031 <td>$form->{country}</td>
2032 <td><input name=shiptocountry size=35 value="$form->{shiptocountry}"></td>
2035 <th align=right nowrap>| . $locale->text('Contact') . qq|</th>
2036 <td>$form->{contact}</td>
2037 <td><input name=shiptocontact size=35 value="$form->{shiptocontact}"></td>
2040 <th align=right nowrap>| . $locale->text('Phone') . qq|</th>
2041 <td>$form->{"$form->{vc}phone"}</td>
2042 <td><input name=shiptophone size=20 value="$form->{shiptophone}"></td>
2045 <th align=right nowrap>| . $locale->text('Fax') . qq|</th>
2046 <td>$form->{"$form->{vc}fax"}</td>
2047 <td><input name=shiptofax size=20 value="$form->{shiptofax}"></td>
2050 <th align=right nowrap>| . $locale->text('E-mail') . qq|</th>
2051 <td>$form->{email}</td>
2052 <td><input name=shiptoemail size=35 value="$form->{shiptoemail}"></td>
2059 <input type=hidden name=nextsub value=$nextsub>
2063 map { delete $form->{$_} }
2064 qw(shiptoname shiptostreet shiptozipcode shiptocity shiptocountry shiptocontact shiptophone shiptofax shiptoemail header);
2065 $form->{title} = $title;
2067 foreach $key (keys %$form) {
2068 $form->{$key} =~ s/\"/"/g;
2069 print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
2077 <input class=submit type=submit name=action value="|
2078 . $locale->text('Continue') . qq|">
2085 $lxdebug->leave_sub();
2089 $lxdebug->enter_sub();
2094 $form->{old_callback} = $form->escape($form->{callback}, 1);
2095 $form->{callback} = $form->escape("$form->{script}?action=display_form", 1);
2096 $form->{old_callback} = $form->escape($form->{old_callback}, 1);
2099 delete $form->{action};
2100 $customer = $form->{customer};
2101 map { $form->{"old_$_"} = $form->{"${_}_$row"} } qw(partnumber description);
2103 # save all other form variables in a previousform variable
2104 $form->{row} = $row;
2105 foreach $key (keys %$form) {
2108 $form->{$key} =~ s/&/%26/g;
2109 $previousform .= qq|$key=$form->{$key}&|;
2112 $previousform = $form->escape($previousform, 1);
2114 $form->{script} = "licenses.pl";
2116 map { $form->{$_} = $form->{"old_$_"} } qw(partnumber description);
2117 map { $form->{$_} = $form->escape($form->{$_}, 1) }
2118 qw(partnumber description);
2120 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|;
2123 $lxdebug->leave_sub();