Customer/Vendor add/edit Dialog auf templates umgestellt.
[kivitendo-erp.git] / bin / mozilla / ct.pl
1 #=====================================================================
2 # LX-Office ERP
3 # Copyright (C) 2004
4 # Based on SQL-Ledger Version 2.1.9
5 # Web http://www.lx-office.org
6 #
7 #=====================================================================
8 # SQL-Ledger Accounting
9 # Copyright (c) 1998-2002
10 #
11 #  Author: Dieter Simader
12 #   Email: dsimader@sql-ledger.org
13 #     Web: http://www.sql-ledger.org
14 #
15 #  Contributors: Reed White <alta@alta-research.com>
16 #
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.
21 #
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.
29 #======================================================================
30 #
31 # customer/vendor module
32 #
33 #======================================================================
34
35 # $locale->text('Customers')
36 # $locale->text('Vendors')
37 # $locale->text('Add Customer')
38 # $locale->text('Add Vendor')
39
40 use CGI;
41 use CGI::Ajax;
42 use POSIX qw(strftime);
43
44 use SL::CT;
45 use SL::ReportGenerator;
46
47 require "bin/mozilla/common.pl";
48 require "bin/mozilla/reportgenerator.pl";
49
50 1;
51
52 # end of main
53
54 sub add {
55   $lxdebug->enter_sub();
56
57   $form->{title} = "Add";
58
59   $form->{callback} =
60     "$form->{script}?action=add&db=$form->{db}&login=$form->{login}&password=$form->{password}"
61     unless $form->{callback};
62
63   CT->populate_drop_down_boxes(\%myconfig, \%$form);
64
65   &form_header;
66   &form_footer;
67
68   $lxdebug->leave_sub();
69 }
70
71 sub search {
72   $lxdebug->enter_sub();
73
74   $form->{IS_CUSTOMER} = $form->{db} eq 'customer';
75
76   $form->get_lists("business_types" => "ALL_BUSINESS_TYPES");
77   $form->{SHOW_BUSINESS_TYPES} = scalar @{ $form->{ALL_BUSINESS_TYPES} } > 0;
78
79   $form->{title} = $form->{IS_CUSTOMER} ? $locale->text('Customers') : $locale->text('Vendors');
80   $form->{fokus} = 'Form.name';
81
82   $form->header();
83   print $form->parse_html_template('ct/search');
84
85   $lxdebug->leave_sub();
86 }
87
88 sub list_names {
89   $lxdebug->enter_sub();
90
91   $form->{IS_CUSTOMER} = $form->{db} eq 'customer';
92
93   CT->search(\%myconfig, \%$form);
94
95   my @options;
96   if ($form->{status} eq 'all') {
97     push @options, $locale->text('All');
98
99   } elsif ($form->{status} eq 'orphaned') {
100     push @options, $locale->text('Orphaned');
101   }
102
103   if ($form->{name}) {
104     push @options, $locale->text('Name') . " : $form->{name}";
105   }
106   if ($form->{contact}) {
107     push @options, $locale->text('Contact') . " : $form->{contact}";
108   }
109   if ($form->{"$form->{db}number"}) {
110     push @options, $locale->text('Number') . qq| : $form->{"$form->{db}number"}|;
111   }
112   if ($form->{email}) {
113     push @options, $locale->text('E-mail') . " : $form->{email}";
114   }
115
116   my @columns = (
117     'id',        'name',  "$form->{db}number", 'address',  'contact',  'phone',
118     'fax',       'email', 'taxnumber',         'sic_code', 'business', 'invnumber',
119     'ordnumber', 'quonumber'
120   );
121
122   my %column_defs = (
123     'id'                => { 'text' => $locale->text('ID'), },
124     "$form->{db}number" => { 'text' => $form->{IS_CUSTOMER} ? $locale->text('Customer Number') : $locale->text('Vendor Number'), },
125     'name'              => { 'text' => $locale->text('Name'), },
126     'address'           => { 'text' => $locale->text('Address'), },
127     'contact'           => { 'text' => $locale->text('Contact'), },
128     'phone'             => { 'text' => $locale->text('Phone'), },
129     'fax'               => { 'text' => $locale->text('Fax'), },
130     'email'             => { 'text' => $locale->text('E-mail'), },
131     'cc'                => { 'text' => $locale->text('Cc'), },
132     'taxnumber'         => { 'text' => $locale->text('Tax Number'), },
133     'sic_code'          => { 'text' => $locale->text('SIC'), },
134     'business'          => { 'text' => $locale->text('Type of Business'), },
135     'invnumber'         => { 'text' => $locale->text('Invoice'), },
136     'ordnumber'         => { 'text' => $form->{IS_CUSTOMER} ? $locale->text('Sales Order') : $locale->text('Purchase Order'), },
137     'quonumber'         => { 'text' => $form->{IS_CUSTOMER} ? $locale->text('Quotation')   : $locale->text('Request for Quotation'), },
138   );
139
140   map { $column_defs{$_}->{visible} = $form->{"l_$_"} eq 'Y' } @columns;
141
142   my @hidden_variables  = (qw(db status obsolete), map { "l_$_" } @columns);
143   my @hidden_nondefault = grep({ $form->{$_} } @hidden_variables);
144   my $callback          = build_std_url('action=list_names', grep { $form->{$_} } @hidden_variables);
145   $form->{callback}     = "$callback&sort=" . E($form->{sort});
146
147   map { $column_defs{$_}->{link} = "${callback}&sort=${_}" } @columns;
148
149   my ($ordertype, $quotationtype, $attachment_basename);
150   if ($form->{IS_CUSTOMER}) {
151     $form->{title}       = $locale->text('Customers');
152     $ordertype           = 'sales_order';
153     $quotationtype       = 'sales_quotation';
154     $attachment_basename = $locale->text('customer_list');
155
156   } else {
157     $form->{title}       = $locale->text('Vendors');
158     $ordertype           = 'purchase_order';
159     $quotationtype       = 'request_quotation';
160     $attachment_basename = $locale->text('vendor_list');
161   }
162
163   my $report = SL::ReportGenerator->new(\%myconfig, $form);
164
165   $report->set_options('top_info_text'         => join("\n", @options),
166                        'raw_bottom_info_text'  => $form->parse_html_template('ct/list_names_bottom'),
167                        'output_format'         => 'HTML',
168                        'title'                 => $form->{title},
169                        'attachment_basename'   => $attachment_basename . strftime('_%Y%m%d', localtime time),
170     );
171   $report->set_options_from_form();
172
173   $report->set_columns(%column_defs);
174   $report->set_column_order(@columns);
175
176   $report->set_export_options('list_names', @hidden_variables);
177
178   $report->set_sort_indicator($form->{sort}, 1);
179
180   my $previous_id;
181
182   foreach my $ref (@{ $form->{CT} }) {
183     my $row = { map { $_ => { 'data' => '' } } @columns };
184
185     if ($ref->{id} ne $previous_id) {
186       $previous_id = $ref->{id};
187       map { $row->{$_}->{data} = $ref->{$_} } @columns;
188
189       $row->{name}->{link}  = build_std_url('action=edit', 'id=' . E($ref->{id}), 'callback', @hidden_nondefault);
190       $row->{email}->{link} = 'mailto:' . E($ref->{email});
191     }
192
193     my $base_url              = build_std_url("script=$ref->{module}.pl", 'action=edit', 'id=' . E($ref->{invid}), 'callback', @hidden_nondefault);
194     $row->{invnumber}->{link} = $base_url;
195     $row->{ordnumber}->{link} = $base_url . "&type=${ordertype}";
196     $row->{quonumber}->{link} = $base_url . "&type=${quotationtype}";
197     my $column                = $ref->{formtype} eq 'invoice' ? 'invnumber' : $ref->{formtype} eq 'order' ? 'ordnumber' : 'quonumber';
198     $row->{$column}->{data}   = $ref->{$column};
199
200     $report->add_data($row);
201   }
202
203   $report->generate_with_headers();
204
205   $lxdebug->leave_sub();
206 }
207
208 sub edit {
209   $lxdebug->enter_sub();
210
211   # show history button
212   $form->{javascript} = qq|<script type=text/javascript src=js/show_history.js></script>|;
213   #/show hhistory button
214   
215   # $locale->text('Edit Customer')
216   # $locale->text('Edit Vendor')
217
218   CT->get_tuple(\%myconfig, \%$form);
219   CT->populate_drop_down_boxes(\%myconfig, \%$form);
220
221   # format " into &quot;
222   map { $form->{$_} =~ s/\"/&quot;/g } keys %$form;
223
224   $form->{title} = "Edit";
225
226   # format discount
227   $form->{discount} *= 100;
228
229   &form_header;
230   &form_footer;
231
232   $lxdebug->leave_sub();
233 }
234
235 sub form_header {
236   $lxdebug->enter_sub();
237
238   $form->get_lists("employees" => "ALL_SALESMEN",
239                    "taxzones"  => "ALL_TAXZONES");
240   $form->get_pricegroup(\%myconfig, { all => 1 });
241
242   $form->{taxincluded}    = ($form->{taxincluded}) ? "checked" : "";
243   $form->{is_admin}       = $myconfig{role} eq 'admin';
244   $form->{is_customer}    = $form->{db}     eq 'customer';
245   $form->{salesman_label} = sub { $_[0]->{name} ne "" ? $_[0]->{name} : $_[0]->{login} };
246   $form->{shipto_label}   = sub { "$_[0]->{shiptoname} $_[0]->{shiptodepartment_1}" };
247   $form->{taxzone_id}     = 0                                                               if !$form->{id};
248   $form->{jsscript}       = 1;
249   $form->{fokus}          = "ct.greeting";
250
251   unshift @{ $form->{SHIPTO} },   +{ shipto_id => '0', shiptoname => '' }, +{ shipto_id => '0', shiptoname => 'Alle' };
252   unshift @{ $form->{CONTACTS} }, +{ cp_id     => '0', cp_name => $locale->text('New contact') };
253
254   push @{ $form->{AJAX} }, map { 
255     new CGI::Ajax( "get_$_" => "$form->{script}?login=$form->{login}&password=$form->{password}&action=get_$_" ) 
256   } qw(shipto contact delivery);
257
258   $form->{title} = $form->{title_save} 
259                 || $locale->text("$form->{title} " . ucfirst $form->{db}) . ($form->{title} eq "Edit" ? " $form->{name}" : '');
260
261 ## LINET: Create a drop-down box with all prior titles and greetings.
262   CT->query_titles_and_greetings(\%myconfig, \%$form);
263   map { $form->{"MB_$_"} = [ map +{ id => $_, description => $_ }, @{ $form->{$_} } ] } qw(TITLES GREETINGS COMPANY_GREETINGS DEPARTMENT);
264 ## /LINET
265
266   $form->header;
267   print $form->parse_html_template('ct/form_header');
268
269   $lxdebug->leave_sub();
270 }
271
272 sub form_footer {
273   $lxdebug->enter_sub();
274
275   $label     = ucfirst $form->{db};
276   $quotation =
277     ($form->{db} eq 'customer')
278     ? $locale->text('Save and Quotation')
279     : $locale->text('Save and RFQ');
280   $arap =
281     ($form->{db} eq 'customer')
282     ? $locale->text('Save and AR Transaction')
283     : $locale->text('Save and AP Transaction');
284
285 ##<input class=submit type=submit name=action value="|.$locale->text("Save and Quotation").qq|">
286 ##<input class=submit type=submit name=action value="|.$locale->text("Save and RFQ").qq|">
287 ##<input class=submit type=submit name=action value="|.$locale->text("Save and AR Transaction").qq|">
288 ##<input class=submit type=submit name=action value="|.$locale->text("Save and AP Transaction").qq|">
289
290   print qq|
291 <input name=id type=hidden id=cvid value=$form->{id}>
292 <input name=business_save type=hidden value="$form->{selectbusiness}">
293 <input name=title_save type=hidden value="$form->{title}">
294
295 <input type=hidden name=login value=$form->{login}>
296 <input type=hidden name=password value=$form->{password}>
297
298 <input type=hidden name=callback value="$form->{callback}">
299 <input type=hidden name=db id=db value=$form->{db}>
300
301
302
303 <br>
304 <input class=submit type=submit name=action accesskey="s" value="|
305     . $locale->text("Save") . qq|">
306 <input class=submit type=submit name=action accesskey="s" value="|
307     . $locale->text("Save and Close") . qq|">
308 <input class=submit type=submit name=action value="$arap">
309 <input class=submit type=submit name=action value="|
310     . $locale->text("Save and Invoice") . qq|">
311 <input class=submit type=submit name=action value="|
312     . $locale->text("Save and Order") . qq|">
313 <input class=submit type=submit name=action value="$quotation">
314 |;
315
316   if ($form->{id} && $form->{status} eq 'orphaned') {
317     print qq|<input class=submit type=submit name=action value="|
318       . $locale->text('Delete')
319       . qq|">\n|;
320   }
321
322   # button for saving history
323   if($form->{id} ne "") {
324     print qq|
325           <input type=button class=submit onclick=set_history_window(|
326           . $form->{id} 
327           . qq|); name=history id=history value=|
328           . $locale->text('history') 
329           . qq|>|;
330   }
331   # /button for saving history
332
333   print qq|
334
335   </form>
336 <script type="text/javascript">
337 //Start Tab Content script for UL with id="maintab" Separate multiple ids each with a comma.
338 initializetabcontent("maintab")
339 </script>
340 </body>
341 </html>
342 |;
343
344   $lxdebug->leave_sub();
345 }
346
347 sub add_transaction {
348   $lxdebug->enter_sub();
349
350 #  # saving the history
351 #  if(!exists $form->{addition}) {
352 #       $form->{addition} = "ADD TRANSACTION";
353 #       $form->save_history($form->dbconnect(\%myconfig));
354 #  }
355 #  # /saving the history
356   
357   $form->isblank("name", $locale->text("Name missing!"));
358   if ($form->{"db"} eq "customer") {
359     CT->save_customer(\%myconfig, \%$form);
360   } else {
361     CT->save_vendor(\%myconfig, \%$form);
362   }
363
364   $form->{callback} = $form->escape($form->{callback}, 1);
365   $name = $form->escape("$form->{name}", 1);
366
367   $form->{callback} =
368     "$form->{script}?login=$form->{login}&password=$form->{password}&action=add&vc=$form->{db}&$form->{db}_id=$form->{id}&$form->{db}=$name&type=$form->{type}&callback=$form->{callback}";
369   $form->redirect;
370
371   $lxdebug->leave_sub();
372 }
373
374 sub save_and_ap_transaction {
375   $lxdebug->enter_sub();
376
377   $form->{script} = "ap.pl";
378   # saving the history
379   if(!exists $form->{addition}) {
380     $form->{snumbers} = qq|invnumber_| . $form->{invnumber};
381         $form->{addition} = "SAVED";
382         $form->save_history($form->dbconnect(\%myconfig));
383   }
384   # /saving the history
385   &add_transaction;
386   $lxdebug->leave_sub();
387 }
388
389 sub save_and_ar_transaction {
390   $lxdebug->enter_sub();
391
392   $form->{script} = "ar.pl";
393   # saving the history
394   if(!exists $form->{addition}) {
395     $form->{snumbers} = qq|invnumber_| . $form->{invnumber};
396         $form->{addition} = "SAVED";
397         $form->save_history($form->dbconnect(\%myconfig));
398   }
399   # /saving the history
400   &add_transaction;
401   $lxdebug->leave_sub();
402 }
403
404 sub save_and_invoice {
405   $lxdebug->enter_sub();
406
407   $form->{script} = ($form->{db} eq 'customer') ? "is.pl" : "ir.pl";
408   $form->{type} = "invoice";
409   # saving the history
410   if(!exists $form->{addition}) {
411     $form->{snumbers} = qq|invnumber_| . $form->{invnumber};
412         $form->{addition} = "SAVED";
413         $form->save_history($form->dbconnect(\%myconfig));
414   }
415   # /saving the history
416   &add_transaction;
417   $lxdebug->leave_sub();
418 }
419
420 sub save_and_rfq {
421   $lxdebug->enter_sub();
422
423   $form->{script} = "oe.pl";
424   $form->{type}   = "request_quotation";
425   # saving the history
426   if(!exists $form->{addition}) {
427     $form->{snumbers} = qq|ordnumber_| . $form->{ordnumber};
428         $form->{addition} = "SAVED";
429         $form->save_history($form->dbconnect(\%myconfig));
430   }
431   # /saving the history
432   &add_transaction;
433   $lxdebug->leave_sub();
434 }
435
436 sub save_and_quotation {
437   $lxdebug->enter_sub();
438
439   $form->{script} = "oe.pl";
440   $form->{type}   = "sales_quotation";
441   # saving the history
442   if(!exists $form->{addition}) {
443     $form->{snumbers} = qq|ordnumber_| . $form->{ordnumber};
444         $form->{addition} = "SAVED";
445         $form->save_history($form->dbconnect(\%myconfig));
446   }
447   # /saving the history
448   &add_transaction;
449   $lxdebug->leave_sub();
450 }
451
452 sub save_and_order {
453   $lxdebug->enter_sub();
454
455   $form->{script} = "oe.pl";
456   $form->{type}   =
457     ($form->{db} eq 'customer') ? "sales_order" : "purchase_order";
458   # saving the history
459   if(!exists $form->{addition}) {
460     $form->{snumbers} = qq|ordnumber_| . $form->{ordnumber};
461         $form->{addition} = "SAVED";
462         $form->save_history($form->dbconnect(\%myconfig));
463   }
464   # /saving the history
465   &add_transaction;
466   $lxdebug->leave_sub();
467 }
468
469 sub save_and_close {
470   $lxdebug->enter_sub();
471
472   # $locale->text('Customer saved!')
473   # $locale->text('Vendor saved!')
474
475   $msg = ucfirst $form->{db};
476   $imsg .= " saved!";
477
478   $form->isblank("name", $locale->text("Name missing!"));
479   if ($form->{"db"} eq "customer") {
480     $rc = CT->save_customer(\%myconfig, \%$form);
481   } else {
482     $rc = CT->save_vendor(\%myconfig, \%$form);
483   }
484   if ($rc == 3) {
485     $form->error($locale->text('customernumber not unique!'));
486   }
487   # saving the history
488   if(!exists $form->{addition}) {
489     $form->{snumbers} = ($form->{"db"} eq "customer" ? qq|customernumber_| . $form->{customernumber} : qq|vendornumber_| . $form->{vendornumber});
490     $form->{addition} = "SAVED";
491         $form->save_history($form->dbconnect(\%myconfig));
492   }
493   # /saving the history
494   $form->redirect($locale->text($msg));
495
496   $lxdebug->leave_sub();
497 }
498
499 sub save {
500   $lxdebug->enter_sub();
501
502   # $locale->text('Customer saved!')
503   # $locale->text('Vendor saved!')
504
505   $msg = ucfirst $form->{db};
506   $imsg .= " saved!";
507
508   $form->isblank("name", $locale->text("Name missing!"));
509
510   my $res;
511   if ($form->{"db"} eq "customer") {
512     $res = CT->save_customer(\%myconfig, \%$form);
513   } else {
514     $res = CT->save_vendor(\%myconfig, \%$form);
515   }
516
517   if (3 == $res) {
518     if ($form->{"db"} eq "customer") {
519       $form->error($locale->text('This customer number is already in use.'));
520     } else {
521       $form->error($locale->text('This vendor number is already in use.'));
522     }
523   }
524   # saving the history
525   if(!exists $form->{addition}) {
526     $form->{snumbers} = ($form->{"db"} eq "customer" ? qq|customernumber_| . $form->{customernumber} : qq|vendornumber_| . $form->{vendornumber});
527         $form->{addition} = "SAVED";
528         $form->save_history($form->dbconnect(\%myconfig));
529   }
530   # /saving the history
531   &edit;
532   exit;
533   $lxdebug->leave_sub();
534 }
535
536 sub delete {
537   $lxdebug->enter_sub();
538
539   # $locale->text('Customer deleted!')
540   # $locale->text('Cannot delete customer!')
541   # $locale->text('Vendor deleted!')
542   # $locale->text('Cannot delete vendor!')
543
544   CT->delete(\%myconfig, \%$form);
545
546   $msg = ucfirst $form->{db};
547   $msg .= " deleted!";
548   # saving the history
549   if(!exists $form->{addition}) {
550     $form->{snumbers} = ($form->{"db"} eq "customer" ? qq|customernumber_| . $form->{customernumber} : qq|vendornumber_| . $form->{vendornumber});
551         $form->{addition} = "DELETED";
552         $form->save_history($form->dbconnect(\%myconfig));
553   }
554   # /saving the history 
555   $form->redirect($locale->text($msg));
556
557   $msg = "Cannot delete $form->{db}";
558   $form->error($locale->text($msg));
559
560   $lxdebug->leave_sub();
561 }
562
563 sub display {
564   $lxdebug->enter_sub();
565
566   &form_header();
567   &form_footer();
568
569   $lxdebug->leave_sub();
570 }
571
572 sub update {
573   $lxdebug->enter_sub();
574
575   &display();
576   $lxdebug->leave_sub();
577 }
578
579 sub get_contact {
580   $lxdebug->enter_sub();
581
582   CT->get_contact(\%myconfig, \%$form);
583
584   my $q = new CGI;
585   $result = "$form->{cp_name}";
586   map { $result .= "__pjx__" . $form->{$_} } qw(cp_greeting cp_title cp_givenname cp_phone1 cp_phone2 cp_email cp_abteilung cp_fax cp_mobile1 cp_mobile2 cp_satphone cp_satfax cp_project cp_privatphone cp_privatemail cp_birthday);
587   print $q->header();
588   print $result;
589   $lxdebug->leave_sub();
590
591 }
592
593 sub get_shipto {
594   $lxdebug->enter_sub();
595
596   CT->get_shipto(\%myconfig, \%$form);
597
598   my $q = new CGI;
599   $result = "$form->{shiptoname}";
600   map { $result .= "__pjx__" . $form->{$_} } qw(shiptodepartment_1 shiptodepartment_2 shiptostreet shiptozipcode shiptocity shiptocountry shiptocontact shiptophone shiptofax shiptoemail);
601   print $q->header();
602   print $result;
603   $lxdebug->leave_sub();
604
605 }
606
607 sub get_delivery {
608   $lxdebug->enter_sub();
609
610   CT->get_delivery(\%myconfig, \%$form );
611
612   @column_index =
613     $form->sort_columns(shiptoname,
614                         invnumber,
615                         ordnumber,
616                         transdate,
617                         description,
618                         qty,
619                         unit,
620                         sellprice);
621
622
623
624   $column_header{shiptoname} =
625     qq|<th class=listheading>| . $locale->text('Shipping Address') . qq|</th>|;
626   $column_header{invnumber} =
627       qq|<th class=listheading>|. $locale->text('Invoice'). qq|</th>|;
628   $column_header{ordnumber} =
629       qq|<th class=listheading>|. $locale->text('Order'). qq|</th>|;
630   $column_header{transdate} =
631     qq|<th class=listheading>| . $locale->text('Invdate') . qq|</th>|;
632   $column_header{description} =
633     qq|<th class=listheading>| . $locale->text('Description') . qq|</th>|;
634   $column_header{qty} =
635     qq|<th class=listheading>| . $locale->text('Qty') . qq|</th>|;
636   $column_header{unit} =
637     qq|<th class=listheading>| . $locale->text('Unit') . qq|</th>|;
638   $column_header{sellprice} =
639     qq|<th class=listheading>| . $locale->text('Sell Price') . qq|</th>|;
640   $result .= qq|
641
642 <table width=100%>
643   <tr>
644     <td>
645       <table width=100%>
646         <tr class=listheading>
647 |;
648
649   map { $result .= "$column_header{$_}\n" } @column_index;
650
651   $result .= qq|
652         </tr>
653 |;
654
655
656   foreach $ref (@{ $form->{DELIVERY} }) {
657
658     if ($ref->{shiptoname} eq $sameshiptoname) {
659       map { $column_data{$_} = "<td>$ref->{$_}&nbsp;</td>" } @column_index;
660       $column_data{shiptoname} = "<td>&nbsp;</td>";
661     } else {
662       map { $column_data{$_} = "<td>$ref->{$_}&nbsp;</td>" } @column_index;
663     }
664     $column_data{sellprice} = "<td>". $form->format_amount(\%myconfig,$ref->{sellprice},2)."&nbsp;</td>";
665     $i++;
666     $i %= 2;
667     $result .= "
668         <tr class=listrow$i>
669 ";
670
671     map { $result .= "$column_data{$_}\n" } @column_index;
672
673     $result .= qq|
674         </tr>
675 |;
676
677     $sameshiptoname = $ref->{shiptoname};
678
679   }
680
681   $result .= qq|
682       </table>
683 |;
684
685
686   my $q = new CGI;
687   print $q->header();
688   print $result;
689   $lxdebug->leave_sub();
690
691 }
692
693 sub continue { call_sub($form->{nextsub}); }