1 #=====================================================================
 
   4 # Based on SQL-Ledger Version 2.1.9
 
   5 # Web http://www.lx-office.org
 
   7 #=====================================================================
 
   8 # SQL-Ledger Accounting
 
   9 # Copyright (c) 1998-2002
 
  11 #  Author: Dieter Simader
 
  12 #   Email: dsimader@sql-ledger.org
 
  13 #     Web: http://www.sql-ledger.org
 
  15 #  Contributors: Reed White <alta@alta-research.com>
 
  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.
 
  29 #======================================================================
 
  31 # customer/vendor module
 
  33 #======================================================================
 
  35 # $locale->text('Customers')
 
  36 # $locale->text('Vendors')
 
  37 # $locale->text('Add Customer')
 
  38 # $locale->text('Add Vendor')
 
  50   $lxdebug->enter_sub();
 
  52   $form->{title} = "Add";
 
  55     "$form->{script}?action=add&db=$form->{db}&path=$form->{path}&login=$form->{login}&password=$form->{password}"
 
  56     unless $form->{callback};
 
  58   CT->taxaccounts(\%myconfig, \%$form);
 
  63   $lxdebug->leave_sub();
 
  67   $lxdebug->enter_sub();
 
  69   $label = ucfirst $form->{db};
 
  70   $form->{title} = $locale->text($label . "s");
 
  72   if ($form->{db} eq 'vendor') {
 
  74                 <td><input name="l_gifi_accno" type=checkbox class=checkbox value=Y> |
 
  75       . $locale->text('GIFI') . qq|</td>
 
  84 <form method=post action=$form->{script}>
 
  86 <input type=hidden name=db value=$form->{db}>
 
  90     <th class=listtop>$form->{title}</th>
 
  97           <th align=right nowrap>| . $locale->text($label . ' Number') . qq|</th>
 
  98           <td><input name=$form->{db}number size=35></td>
 
 101           <th align=right nowrap>| . $locale->text('Company Name') . qq|</th>
 
 102           <td><input name=name size=35></td>
 
 105           <th align=right nowrap>| . $locale->text('Contact') . qq|</th>
 
 106           <td><input name=contact size=35></td>
 
 109           <th align=right nowrap>| . $locale->text('E-mail') . qq|</th>
 
 110           <td><input name=email size=35></td>
 
 114           <td><input name=status class=radio type=radio value=all checked> |
 
 115     . $locale->text('All') . qq|
 
 116           <input name=status class=radio type=radio value=orphaned> |
 
 117     . $locale->text('Orphaned') . qq|</td>
 
 120           <th align=right nowrap>| . $locale->text('Include in Report') . qq|</th>
 
 124                 <td><input name="l_id" type=checkbox class=checkbox value=Y> |
 
 125     . $locale->text('ID') . qq|</td>
 
 126                 <td><input name="l_$form->{db}number" type=checkbox class=checkbox value=Y> |
 
 127     . $locale->text($label . ' Number') . qq|</td>
 
 128                 <td><input name="l_name" type=checkbox class=checkbox value=Y checked> |
 
 129     . $locale->text('Company Name') . qq|</td>
 
 130                 <td><input name="l_address" type=checkbox class=checkbox value=Y> |
 
 131     . $locale->text('Address') . qq|</td>
 
 134                 <td><input name="l_contact" type=checkbox class=checkbox value=Y checked> |
 
 135     . $locale->text('Contact') . qq|</td>
 
 136                 <td><input name="l_phone" type=checkbox class=checkbox value=Y checked> |
 
 137     . $locale->text('Phone') . qq|</td>
 
 138                 <td><input name="l_fax" type=checkbox class=checkbox value=Y> |
 
 139     . $locale->text('Fax') . qq|</td>
 
 140                 <td><input name="l_email" type=checkbox class=checkbox value=Y checked> |
 
 141     . $locale->text('E-mail') . qq|</td>
 
 144                 <td><input name="l_taxnumber" type=checkbox class=checkbox value=Y> |
 
 145     . $locale->text('Tax Number') . qq|</td>
 
 147                 <td><input name="l_sic_code" type=checkbox class=checkbox value=Y> |
 
 148     . $locale->text('SIC') . qq|</td>
 
 149                 <td><input name="l_business" type=checkbox class=checkbox value=Y> |
 
 150     . $locale->text('Type of Business') . qq|</td>
 
 153                 <td><input name="l_invnumber" type=checkbox class=checkbox value=Y> |
 
 154     . $locale->text('Invoices') . qq|</td>
 
 155                 <td><input name="l_ordnumber" type=checkbox class=checkbox value=Y> |
 
 156     . $locale->text('Orders') . qq|</td>
 
 157                 <td><input name="l_quonumber" type=checkbox class=checkbox value=Y> |
 
 158     . $locale->text('Quotations') . qq|</td>
 
 167     <td><hr size=3 noshade></td>
 
 171 <input type=hidden name=nextsub value=list_names>
 
 173 <input type=hidden name=path value=$form->{path}>
 
 174 <input type=hidden name=login value=$form->{login}>
 
 175 <input type=hidden name=password value=$form->{password}>
 
 178 <input type=submit class=submit name=action value="|
 
 179     . $locale->text('Continue') . qq|">
 
 185   $lxdebug->leave_sub();
 
 188 sub search_delivery {
 
 189   $lxdebug->enter_sub();
 
 191   $label = ucfirst $form->{db};
 
 192   $form->{title} = $locale->text($label . "s");
 
 194   if ($form->{db} eq 'vendor') {
 
 196                 <td><input name="l_gifi_accno" type=checkbox class=checkbox value=Y> |
 
 197       . $locale->text('GIFI') . qq|</td>
 
 206 <form method=post action=$form->{script}>
 
 208 <input type=hidden name=db value=$form->{db}>
 
 212     <th class=listtop>$form->{title}</th>
 
 219           <th align=right nowrap>| . $locale->text($label . ' Number') . qq|</th>
 
 220           <td><input name=$form->{db}number size=35></td>
 
 223           <th align=right nowrap>| . $locale->text('Company Name') . qq|</th>
 
 224           <td><input name=name size=35></td>
 
 227           <th align=right nowrap>| . $locale->text('Contact') . qq|</th>
 
 228           <td><input name=contact size=35></td>
 
 231           <th align=right nowrap>| . $locale->text('E-mail') . qq|</th>
 
 232           <td><input name=email size=35></td>
 
 236           <td><input name=status class=radio type=radio value=all checked> |
 
 237     . $locale->text('All') . qq|
 
 238           <input name=status class=radio type=radio value=orphaned> |
 
 239     . $locale->text('Orphaned') . qq|</td>
 
 242           <th align=right nowrap>| . $locale->text('Include in Report') . qq|</th>
 
 246                 <td><input name="l_id" type=checkbox class=checkbox value=Y> |
 
 247     . $locale->text('ID') . qq|</td>
 
 248                 <td><input name="l_$form->{db}number" type=checkbox class=checkbox value=Y> |
 
 249     . $locale->text($label . ' Number') . qq|</td>
 
 250                 <td><input name="l_name" type=checkbox class=checkbox value=Y checked> |
 
 251     . $locale->text('Company Name') . qq|</td>
 
 252                 <td><input name="l_address" type=checkbox class=checkbox value=Y> |
 
 253     . $locale->text('Address') . qq|</td>
 
 256                 <td><input name="l_contact" type=checkbox class=checkbox value=Y checked> |
 
 257     . $locale->text('Contact') . qq|</td>
 
 258                 <td><input name="l_phone" type=checkbox class=checkbox value=Y checked> |
 
 259     . $locale->text('Phone') . qq|</td>
 
 260                 <td><input name="l_fax" type=checkbox class=checkbox value=Y> |
 
 261     . $locale->text('Fax') . qq|</td>
 
 262                 <td><input name="l_email" type=checkbox class=checkbox value=Y checked> |
 
 263     . $locale->text('E-mail') . qq|</td>
 
 266                 <td><input name="l_taxnumber" type=checkbox class=checkbox value=Y> |
 
 267     . $locale->text('Tax Number') . qq|</td>
 
 269                 <td><input name="l_sic_code" type=checkbox class=checkbox value=Y> |
 
 270     . $locale->text('SIC') . qq|</td>
 
 271                 <td><input name="l_business" type=checkbox class=checkbox value=Y> |
 
 272     . $locale->text('Type of Business') . qq|</td>
 
 275                 <td><input name="l_invnumber" type=checkbox class=checkbox value=Y> |
 
 276     . $locale->text('Invoices') . qq|</td>
 
 277                 <td><input name="l_ordnumber" type=checkbox class=checkbox value=Y> |
 
 278     . $locale->text('Orders') . qq|</td>
 
 279                 <td><input name="l_quonumber" type=checkbox class=checkbox value=Y> |
 
 280     . $locale->text('Quotations') . qq|</td>
 
 289     <td><hr size=3 noshade></td>
 
 293 <input type=hidden name=nextsub value=list_names>
 
 295 <input type=hidden name=path value=$form->{path}>
 
 296 <input type=hidden name=login value=$form->{login}>
 
 297 <input type=hidden name=password value=$form->{password}>
 
 300 <input type=submit class=submit name=action value="|
 
 301     . $locale->text('Continue') . qq|">
 
 307   $lxdebug->leave_sub();
 
 311   $lxdebug->enter_sub();
 
 313   CT->search(\%myconfig, \%$form);
 
 316     "$form->{script}?action=list_names&db=$form->{db}&path=$form->{path}&login=$form->{login}&password=$form->{password}&status=$form->{status}";
 
 320     $form->sort_columns(id, name,
 
 321                         "$form->{db}number", address,
 
 324                         taxnumber,           gifi_accno,
 
 326                         invnumber,           ordnumber,
 
 329   foreach $item (@columns) {
 
 330     if ($form->{"l_$item"} eq "Y") {
 
 331       push @column_index, $item;
 
 333       # add column to href and callback
 
 334       $callback .= "&l_$item=Y";
 
 335       $href     .= "&l_$item=Y";
 
 339     ($form->{db} eq "customer")
 
 340     ? $locale->text('Customer Number')
 
 341     : $locale->text('Vendor Number');
 
 343   if ($form->{status} eq 'all') {
 
 344     $option = $locale->text('All');
 
 346   if ($form->{status} eq 'orphaned') {
 
 347     $option .= $locale->text('Orphaned');
 
 350     $callback .= "&name=" . $form->escape($form->{name}, 1);
 
 351     $href .= "&name=" . $form->escape($form->{name});
 
 352     $option .= "\n<br>" . $locale->text('Name') . " : $form->{name}";
 
 354   if ($form->{contact}) {
 
 355     $callback .= "&contact=" . $form->escape($form->{contact}, 1);
 
 356     $href .= "&contact=" . $form->escape($form->{contact});
 
 357     $option .= "\n<br>" . $locale->text('Contact') . " : $form->{contact}";
 
 359   if ($form->{"$form->{db}number"}) {
 
 361       qq|&$form->{db}number=| . $form->escape($form->{"$form->{db}number"}, 1);
 
 363       "&$form->{db}number=" . $form->escape($form->{"$form->{db}number"});
 
 365       "\n<br>" . $locale->text('Number') . qq| : $form->{"$form->{db}number"}|;
 
 367   if ($form->{email}) {
 
 368     $callback .= "&email=" . $form->escape($form->{email}, 1);
 
 369     $href .= "&email=" . $form->escape($form->{email});
 
 370     $option .= "\n<br>" . $locale->text('E-mail') . " : $form->{email}";
 
 373   $form->{callback} = "$callback&sort=$form->{sort}";
 
 374   $callback = $form->escape($form->{callback});
 
 377     qq|<th class=listheading>| . $locale->text('ID') . qq|</th>|;
 
 378   $column_header{"$form->{db}number"} =
 
 379     qq|<th><a class=listheading href=$href&sort=$form->{db}number>$number</a></th>|;
 
 380   $column_header{name} =
 
 381       qq|<th><a class=listheading href=$href&sort=name>|
 
 382     . $locale->text('Name')
 
 384   $column_header{address} =
 
 385       qq|<th><a class=listheading href=$href&sort=address>|
 
 386     . $locale->text('Address')
 
 388   $column_header{contact} =
 
 389       qq|<th><a class=listheading href=$href&sort=contact>|
 
 390     . $locale->text('Contact')
 
 392   $column_header{phone} =
 
 393       qq|<th><a class=listheading href=$href&sort=phone>|
 
 394     . $locale->text('Phone')
 
 396   $column_header{fax} =
 
 397       qq|<th><a class=listheading href=$href&sort=fax>|
 
 398     . $locale->text('Fax')
 
 400   $column_header{email} =
 
 401       qq|<th><a class=listheading href=$href&sort=email>|
 
 402     . $locale->text('E-mail')
 
 405       qq|<th><a class=listheading href=$href&sort=cc>|
 
 406     . $locale->text('Cc')
 
 409   $column_header{taxnumber} =
 
 410       qq|<th><a class=listheading href=$href&sort=taxnumber>|
 
 411     . $locale->text('Tax Number')
 
 413   $column_header{gifi_accno} =
 
 414       qq|<th><a class=listheading href=$href&sort=gifi_accno>|
 
 415     . $locale->text('GIFI')
 
 417   $column_header{sic_code} =
 
 418       qq|<th><a class=listheading href=$href&sort=sic_code>|
 
 419     . $locale->text('SIC')
 
 421   $column_header{business} =
 
 422       qq|<th><a class=listheading href=$href&sort=business>|
 
 423     . $locale->text('Type of Business')
 
 426   $column_header{invnumber} =
 
 427       qq|<th><a class=listheading href=$href&sort=invnumber>|
 
 428     . $locale->text('Invoice')
 
 430   $column_header{ordnumber} =
 
 431       qq|<th><a class=listheading href=$href&sort=ordnumber>|
 
 432     . $locale->text('Order')
 
 434   $column_header{quonumber} =
 
 435       qq|<th><a class=listheading href=$href&sort=quonumber>|
 
 436     . $locale->text('Quotation')
 
 439   $label = ucfirst $form->{db} . "s";
 
 440   $form->{title} = $locale->text($label);
 
 449     <th class=listtop>$form->{title}</th>
 
 458         <tr class=listheading>
 
 461   map { print "$column_header{$_}\n" } @column_index;
 
 467   $ordertype = ($form->{db} eq 'customer') ? 'sales_order' : 'purchase_order';
 
 469     ($form->{db} eq 'customer') ? 'sales_quotation' : 'request_quotation';
 
 471   foreach $ref (@{ $form->{CT} }) {
 
 473     if ($ref->{id} eq $sameid) {
 
 474       map { $column_data{$_} = "<td> </td>" } @column_index;
 
 476       map { $column_data{$_} = "<td>$ref->{$_} </td>" } @column_index;
 
 478       map { $column_data{$_} = "<td>$ref->{$_} </td>" }
 
 479         (invnumber, ordnumber, quonumber);
 
 482         "<td align=left><a href=$form->{script}?action=edit&id=$ref->{id}&db=$form->{db}&path=$form->{path}&login=$form->{login}&password=$form->{password}&status=$form->{status}&callback=$callback>$ref->{name} </td>";
 
 485         $email = $ref->{email};
 
 486         $email =~ s/</\</;
 
 487         $email =~ s/>/\>/;
 
 489         $column_data{email} =
 
 490           qq|<td><a href="mailto:$ref->{email}">$email</a></td>|;
 
 495     if ($ref->{formtype} eq 'invoice') {
 
 496       $column_data{invnumber} =
 
 497         "<td><a href=$ref->{module}.pl?action=edit&id=$ref->{invid}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{invnumber} </td>";
 
 500     if ($ref->{formtype} eq 'order') {
 
 501       $column_data{ordnumber} =
 
 502         "<td><a href=$ref->{module}.pl?action=edit&id=$ref->{invid}&type=$ordertype&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{ordnumber} </td>";
 
 505     if ($ref->{formtype} eq 'quotation') {
 
 506       $column_data{quonumber} =
 
 507         "<td><a href=$ref->{module}.pl?action=edit&id=$ref->{invid}&type=$quotationtype&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{quonumber} </td>";
 
 516     map { print "$column_data{$_}\n" } @column_index;
 
 522     $sameid = $ref->{id};
 
 531     <td><hr size=3 noshade></td>
 
 536 <form method=post action=$form->{script}>
 
 538 <input name=callback type=hidden value="$form->{callback}">
 
 539 <input name=db type=hidden value=$form->{db}>
 
 541 <input type=hidden name=path value=$form->{path}>
 
 542 <input type=hidden name=login value=$form->{login}>
 
 543 <input type=hidden name=password value=$form->{password}>
 
 545 <input class=submit type=submit name=action value="|
 
 546     . $locale->text('Add') . qq|">
 
 554   $lxdebug->leave_sub();
 
 558   $lxdebug->enter_sub();
 
 560   # $locale->text('Edit Customer')
 
 561   # $locale->text('Edit Vendor')
 
 563   CT->get_tuple(\%myconfig, \%$form);
 
 565   # format " into "
 
 566   map { $form->{$_} =~ s/\"/"/g } keys %$form;
 
 568   $form->{title} = "Edit";
 
 571   $form->{discount} *= 100;
 
 576   $lxdebug->leave_sub();
 
 580   $lxdebug->enter_sub();
 
 582   $form->{taxincluded} = ($form->{taxincluded}) ? "checked" : "";
 
 583   $form->{creditlimit} =
 
 584     $form->format_amount(\%myconfig, $form->{creditlimit}, 0);
 
 585   $form->{discount} = $form->format_amount(\%myconfig, $form->{discount});
 
 587   if ($myconfig{role} eq 'admin') {
 
 590           <th align=right nowrap>| . $locale->text('Bcc') . qq|</th>
 
 591           <td><input name=bcc size=35 value="$form->{bcc}"></td>
 
 595   $form->{obsolete} = "checked" if $form->{obsolete};
 
 597   $lang = qq|<option value=""></option>|;
 
 598   foreach $item (@{ $form->{languages} }) {
 
 599     if ($form->{language_id} eq $item->{id}) {
 
 600       $lang .= qq|<option value="$item->{id}" selected>$item->{description}</option>|;
 
 602       $lang .= qq|<option value="$item->{id}">$item->{description}</option>|;
 
 606   $payment = qq|<option value=""></option>|;
 
 607   foreach $item (@{ $form->{payment_terms} }) {
 
 608     if ($form->{payment_id} eq $item->{id}) {
 
 609       $payment .= qq|<option value="$item->{id}" selected>$item->{description}</option>|;
 
 611       $payment .= qq|<option value="$item->{id}">$item->{description}</option>|;
 
 616     if ($form->{db} eq "customer") {
 
 617       $form->{taxzone_id} = 0;
 
 619       $form->{taxzone_id} = 0;
 
 623   if (@{ $form->{TAXZONE} }) {
 
 624     foreach $item (@{ $form->{TAXZONE} }) {
 
 625       if ($item->{id} == $form->{taxzone_id}) {
 
 626         $form->{selecttaxzone} .=
 
 627           "<option value=$item->{id} selected>$item->{description}\n";
 
 629         $form->{selecttaxzone} .=
 
 630           "<option value=$item->{id}>$item->{description}\n";
 
 638                 <th align=right>| . $locale->text('Steuersatz') . qq|</th>
 
 639                 <td><select name=taxzone_id>$form->{selecttaxzone}</select></td>
 
 640                 <input type=hidden name=selecttaxzone value="$form->{selecttaxzone}">
 
 644     "$form->{script}?login=$form->{login}&path=$form->{path}&password=$form->{password}&action=get_contact";
 
 646   my $pjx = new CGI::Ajax( 'get_contact' => $get_contact_url );
 
 647   $form->{selectcontact} = "<option value=0></option>";
 
 648   if (@{ $form->{CONTACTS} }) {
 
 649     foreach $item (@{ $form->{CONTACTS} }) {
 
 650       if ($item->{cp_id} == $form->{cp_id}) {
 
 651         $form->{selectcontact} .=
 
 652           qq|<option value=$item->{cp_id} selected>$item->{cp_name}</option>\n|;
 
 654         $form->{selectcontact} .=
 
 655           qq|<option value=$item->{cp_id}>$item->{cp_name}</option>\n|;
 
 660   push(@ { $form->{AJAX} }, $pjx);
 
 661   $ansprechpartner = qq|
 
 663                 <th align=right>| . $locale->text('Ansprechpartner') . qq|</th>
 
 664                 <td><select id=cp_id name=cp_id onChange="get_contact(['cp_id__' + this.value], ['cp_name', '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'])">$form->{selectcontact}</select></td>
 
 665                 <input type=hidden name=selectcontact value="$form->{selectcontact}">
 
 668     "$form->{script}?login=$form->{login}&path=$form->{path}&password=$form->{password}&action=get_shipto";
 
 670   my $pjy = new CGI::Ajax( 'get_shipto' => $get_shipto_url );
 
 671   $form->{selectshipto} = "<option value=0></option>";
 
 672   $form->{selectshipto} .= "<option value=0>Alle</option>";
 
 673   if (@{ $form->{SHIPTO} }) {
 
 674     foreach $item (@{ $form->{SHIPTO} }) {
 
 675       if ($item->{shipto_id} == $form->{shipto_id}) {
 
 676         $form->{selectshipto} .=
 
 677           "<option value=$item->{shipto_id} selected>$item->{shiptoname} $item->{shiptodepartment_1}\n";
 
 679         $form->{selectshipto} .=
 
 680           "<option value=$item->{shipto_id}>$item->{shiptoname} $item->{shiptodepartment_1}\n";
 
 685   push(@ { $form->{AJAX} }, $pjy);
 
 689                 <th align=right>| . $locale->text('Shipping Address') . qq|</th>
 
 690                 <td><select id=shipto_id name=shipto_id onChange="get_shipto(['shipto_id__' + this.value], ['shiptoname','shiptodepartment_1', 'shiptodepartment_2','shiptostreet','shiptozipcode','shiptocity','shiptocountry','shiptocontact','shiptophone','shiptofax','shiptoemail'])">$form->{selectshipto}</select></td>
 
 691                 <input type=hidden name=selectshipto value="$form->{selectshipto}">
 
 696     "$form->{script}?login=$form->{login}&path=$form->{path}&password=$form->{password}&action=get_delivery";
 
 698   my $pjz = new CGI::Ajax( 'get_delivery' => $get_delivery_url );
 
 700   push(@ { $form->{AJAX} }, $pjz);
 
 704                 <th align=right>| . $locale->text('Shipping Address') . qq|</th>
 
 705                 <td><select id=delivery_id name=delivery_id onChange="get_delivery(['shipto_id__' + this.value, 'from__' + from.value, 'to__' + to.value, 'id__' + cvid.value, 'db__' + db.value], ['delivery'])">$form->{selectshipto}</select></td>
 
 708   foreach $item (split / /, $form->{taxaccounts}) {
 
 709     if (($form->{tax}{$item}{taxable}) || !($form->{id})) {
 
 711         qq| <input name="tax_$item" value=1 class=checkbox type=checkbox checked> <b>$form->{tax}{$item}{description}</b>|;
 
 714         qq| <input name="tax_$item" value=1 class=checkbox type=checkbox> <b>$form->{tax}{$item}{description}</b>|;
 
 724     <th align=right>| . $locale->text('Taxable') . qq|</th>
 
 729           <td><input name=taxincluded class=checkbox type=checkbox value=1 $form->{taxincluded}></td>
 
 730           <th align=left>| . $locale->text('Tax Included') . qq|</th>
 
 737   $form->{selectbusiness} = qq|<option>\n|;
 
 739     $form->{selectbusiness} .=
 
 740       qq|<option value=$_->{id}>$_->{description}\n|
 
 741   } @{ $form->{all_business} };
 
 742   if ($form->{business_save}) {
 
 743     $form->{selectbusiness} = $form->{business_save};
 
 745   $form->{selectbusiness} =~
 
 746     s/<option value=$form->{business}>/<option value=$form->{business} selected>/;
 
 748   $label = ucfirst $form->{db};
 
 749   if ($form->{title} eq "Edit") {
 
 750     $form->{title} = $locale->text("$form->{title} $label") . " $form->{name}";
 
 752     $form->{title} = $locale->text("$form->{title} $label");
 
 754   if ($form->{title_save}) {
 
 755     $form->{title} = $form->{title_save};
 
 757   if ($form->{db} eq 'vendor') {
 
 759            <th align=right>| . $locale->text('Kundennummer') . qq|</th>
 
 760            <td><input name=v_customer_id size=10 tabindex=18 maxlength=35 value="$form->{v_customer_id}"></td>
 
 764   if ($form->{db} eq 'customer') {
 
 767            <th align=right>| . $locale->text('KNr. beim Kunden') . qq|</th>
 
 768            <td><input name=c_vendor_id size=10 tabindex=18 maxlength=35 value="$form->{c_vendor_id}"></td>
 
 771   $business_salesman = "";
 
 772   $business          = "<th></th><td></td>";
 
 774     $business_salesman = qq|
 
 778              <th align=right>| . $locale->text('Type of Business') . qq|</th>
 
 779              <td><select name=business tabindex=1>$form->{selectbusiness}</select></td>
 
 780              <th align=right>| . $locale->text('Salesman') . qq|</th>
 
 781              <td><input name=salesman tabindex=2 value="$form->{salesman}"></td>
 
 782              <input type=hidden name=salesman_id value="$form->{salesman_id}">
 
 783              <input type=hidden name=oldsalesman value="$form->{oldsalesman}">
 
 788              <th align=right>| . $locale->text('Username') . qq|</th>
 
 789              <td><input name=username maxlength=50 tabindex=22 value="$form->{username}"></td>
 
 790              <th align=right>| . $locale->text('Password') . qq|</th>
 
 791              <td><input name=user_password maxlength=12 tabindex=23 value="$form->{user_password}"></td>|;
 
 794           <th align=right>| . $locale->text('Type of Business') . qq|</th>
 
 795           <td><select name=business tabindex=22>$form->{selectbusiness}</select></td>
 
 799 ## LINET: Create a drop-down box with all prior titles and greetings.
 
 800   CT->query_titles_and_greetings(\%myconfig, \%$form);
 
 802   $select_title = qq| <select name=selected_cp_title><option></option>|;
 
 803   map({ $select_title .= qq|<option>$_</option>|; } @{ $form->{TITLES} });
 
 804   $select_title .= qq|</select>|;
 
 807     qq| <select name=selected_cp_greeting><option></option>|;
 
 809      { $select_greeting .= qq|<option>$_</option>|; } @{ $form->{GREETINGS} });
 
 810   $select_greeting .= qq|</select>|;
 
 812   $select_company_greeting =
 
 813     qq| <select name=selected_company_greeting><option></option>|;
 
 815      { $select_company_greeting .= qq|<option>$_</option>|; } @{ $form->{COMPANY_GREETINGS} });
 
 816   $select_company_greeting .= qq|</select>|;
 
 819     qq| <select name=selected_cp_abteilung><option></option>|;
 
 821      { $select_department .= qq|<option>$_</option>|; } @{ $form->{DEPARTMENT} });
 
 822   $select_department .= qq|</select>|;
 
 825   if ($form->{db} eq 'customer') {
 
 827     #get pricegroup and form it
 
 828     $form->get_pricegroup(\%myconfig, { all => 1 });
 
 830     $form->{pricegroup}    = "$form->{klass}";
 
 831     $form->{pricegroup_id} = "$form->{klass}";
 
 833     if (@{ $form->{all_pricegroup} }) {
 
 835       $form->{selectpricegroup} = qq|<option>\n|;
 
 837         $form->{selectpricegroup} .=
 
 838           qq|<option value="$_->{id}">$_->{pricegroup}\n|
 
 839       } @{ $form->{all_pricegroup} };
 
 842     if ($form->{selectpricegroup}) {
 
 843       $form->{selectpricegroup} = $form->unescape($form->{selectpricegroup});
 
 846         qq|<input type=hidden name=selectpricegroup value="|
 
 847         . $form->escape($form->{selectpricegroup}, 1) . qq|">|;
 
 849       $form->{selectpricegroup} =~
 
 850         s/(<option value="\Q$form->{klass}\E")/$1 selected/;
 
 853         qq|<select name=klass tabindex=24>$form->{selectpricegroup}</select>|;
 
 858   # $locale->text('Customer Number')
 
 859   # $locale->text('Vendor Number')
 
 860   $form->{fokus} = "ct.greeting";
 
 861   $form->{jsscript} = 1;
 
 865 <body onLoad="fokus()">
 
 868     <th class=listtop>$form->{title}</th>
 
 873 <form method=post name="ct" action=$form->{script} onKeyUp="highlight(event)" onClick="highlight(event)">
 
 877 <ul id="maintab" class="shadetabs">
 
 878 <li class="selected"><a href="#" rel="billing">|
 
 879     . $locale->text('Billing Address') . qq|</a></li>
 
 880 <li><a href="#" rel="shipto">|
 
 881     . $locale->text('Shipping Address') . qq|</a></li>
 
 882 <li><a href="#" rel="contacts">Ansprechpartner</a></li>
 
 883 <li><a href="#" rel="deliveries">|
 
 884     . $locale->text('Lieferungen') . qq|</a></li>
 
 888 <div class="tabcontentstyle">
 
 890 <div id="billing" class="tabcontent">
 
 896           <th align=right nowrap>| . $locale->text($label . ' Number') . qq|</th>
 
 897           <td><input name="$form->{db}number" size=35 maxlength=35 value="$form->{"$form->{db}number"}"></td>
 
 900           <th align=right nowrap>| . $locale->text('Greeting') . qq|</th>
 
 901           <td><input id=greeting name=greeting size=30 maxlength=30 value="$form->{greeting}"> 
 
 902           $select_company_greeting</td>
 
 905           <th align=right nowrap>| . $locale->text('Company Name') . qq|</th>
 
 906           <td><input name=name size=35 maxlength=75 value="$form->{name}"></td>
 
 909           <th align=right nowrap>| . $locale->text('Abteilung') . qq|</th>
 
 910           <td><input name=department_1 size=16 maxlength=75 value="$form->{department_1}">
 
 911           <input name=department_2 size=16 maxlength=75 value="$form->{department_2}"></td>
 
 914           <th align=right nowrap>| . $locale->text('Street') . qq|</th>
 
 915           <td><input name=street size=35 maxlength=75 value="$form->{street}"></td>
 
 918           <th align=right nowrap>|
 
 919     . $locale->text('Zipcode') . "/" . $locale->text('City') . qq|</th>
 
 920           <td><input name=zipcode size=5 maxlength=10 value="$form->{zipcode}">
 
 921           <input name=city size=30 maxlength=75 value="$form->{city}"></td>
 
 924           <th align=right nowrap>| . $locale->text('Country') . qq|</th>
 
 925           <td><input name=country size=35 maxlength=75 value="$form->{country}"></td>
 
 928           <th align=right nowrap>| . $locale->text('Contact') . qq|</th>
 
 929           <td><input name=contact size=28 maxlength=75 value="$form->{contact}"></td>
 
 932           <th align=right nowrap>| . $locale->text('Phone') . qq|</th>
 
 933           <td><input name=phone size=30 maxlength=30 value="$form->{phone}"></td>
 
 936           <th align=right nowrap>| . $locale->text('Fax') . qq|</th>
 
 937           <td><input name=fax size=30 maxlength=30 value="$form->{fax}"></td>
 
 940           <th align=right nowrap>| . $locale->text('E-mail') . qq|</th>
 
 941           <td><input name=email size=45 value="$form->{email}"></td>
 
 944           <th align=right nowrap>| . $locale->text('Homepage') . qq|</th>
 
 945           <td><input name=homepage size=45 value="$form->{homepage}"></td>
 
 950           <th align=right>| . $locale->text('Credit Limit') . qq|</th>
 
 951           <td><input name=creditlimit size=9 value="$form->{creditlimit}"></td>
 
 952           <input type="hidden" name="terms" value="$form->{terms}">
 
 953           <th align=right>| . $locale->text('Payment Terms') . qq|</th>
 
 954           <td><select name=payment_id>$payment</select></td>
 
 955           <th align=right>| . $locale->text('Discount') . qq|</th>
 
 956           <td><input name=discount size=4 value="$form->{discount}">
 
 960           <th align=right>| . $locale->text('Tax Number / SSN') . qq|</th>
 
 961           <td><input name=taxnumber size=20 value="$form->{taxnumber}"></td>
 
 962           <th align=right>| . $locale->text('USt-IdNr.') . qq|</th>
 
 963           <td><input name="ustid" maxlength="14" size="20" value="$form->{ustid}"></td>
 
 967           <th align=right>| . $locale->text('Account Number') . qq|</th>
 
 968           <td><input name=account_number size=10 value="$form->{account_number}"></td>
 
 969           <th align=right>| . $locale->text('Bank Code Number') . qq|</th>
 
 970           <td><input name=bank_code size=10 value="$form->{bank_code}"></td>
 
 971           <th align=right>| . $locale->text('Bank') . qq|</th>
 
 972           <td><input name=bank size=30 value="$form->{bank}"></td>
 
 976           <th align=right>| . $locale->text('Language') . qq|</th>
 
 977           <td><select name=language_id tabindex=23>$lang
 
 980   if ($form->{db} eq 'customer') {
 
 983           <th align=right>| . $locale->text('Preisklasse') . qq|</th>
 
 984           <td>$pricegroup</td>|;
 
 988           <td align=right>| . $locale->text('Obsolete') . qq|</td>
 
 989           <td><input name=obsolete class=checkbox type=checkbox value=1 $form->{obsolete}></td>
 
 995     <th align=left nowrap>| . $locale->text('Notes') . qq|</th>
 
 998     <td><textarea name=notes rows=3 cols=60 wrap=soft>$form->{notes}</textarea></td>
 
1005 <br style="clear: left" /></div>|;
 
1008       <div id="shipto" class="tabcontent">
 
1013           <th align=right nowrap>| . $locale->text('Company Name') . qq|</th>
 
1014           <td><input id=shiptoname name=shiptoname size=35 maxlength=75 value="$form->{shiptoname}"></td>
 
1017           <th align=right nowrap>| . $locale->text('Abteilung') . qq|</th>
 
1018           <td><input id=shiptodepartment_1 name=shiptodepartment_1 size=16 maxlength=75 value="$form->{shiptodepartment_1}">
 
1019           <input id=shiptodepartment_2 name=shiptodepartment_2 size=16 maxlength=75 value="$form->{shiptodepartment_2}"></td>
 
1022           <th align=right nowrap>| . $locale->text('Street') . qq|</th>
 
1023           <td><input id=shiptostreet name=shiptostreet size=35 maxlength=75 value="$form->{shiptostreet}"></td>
 
1026           <th align=right nowrap>|
 
1027     . $locale->text('Zipcode') . "/" . $locale->text('City') . qq|</th>
 
1028           <td><input id=shiptozipcode name=shiptozipcode size=5 maxlength=10 value="$form->{shiptozipcode}">
 
1029           <input id=shiptocity name=shiptocity size=30 maxlength=75 value="$form->{shiptocity}"></td>
 
1032           <th align=right nowrap>| . $locale->text('Country') . qq|</th>
 
1033           <td><input id=shiptocountry name=shiptocountry size=35 maxlength=35 value="$form->{shiptocountry}"></td>
 
1036           <th align=right nowrap>| . $locale->text('Contact') . qq|</th>
 
1037           <td><input id=shiptocontact name=shiptocontact size=30 maxlength=75 value="$form->{shiptocontact}"></td>
 
1040           <th align=right nowrap>| . $locale->text('Phone') . qq|</th>
 
1041           <td><input id=shiptophone name=shiptophone size=30 maxlength=30 value="$form->{shiptophone}"></td>
 
1044           <th align=right nowrap>| . $locale->text('Fax') . qq|</th>
 
1045           <td><input id=shiptofax name=shiptofax size=30 maxlength=30 value="$form->{shiptofax}"></td>
 
1048           <th align=right nowrap>| . $locale->text('E-mail') . qq|</th>
 
1049           <td><input id=shiptoemail name=shiptoemail size=45 value="$form->{shiptoemail}"></td>
 
1059 <br style="clear: left" /></div>|;
 
1062 ##LINET - added fields for contact person
 
1064 <div id="contacts" class="tabcontent">
 
1068                 <input type=hidden name=cp_id value=$form->{cp_id}>
 
1072                   <th align=left nowrap>| . $locale->text('Greeting') . qq|</th>
 
1073                   <td><input id=cp_greeting name=cp_greeting size=30 maxlength=30 value="$form->{cp_greeting}"> 
 
1074                   $select_greeting</td>
 
1077                   <th align=left nowrap>| . $locale->text('Title') . qq|</th>
 
1078                   <td><input id=cp_title name=cp_title size=30 maxlength=30 value="$form->{cp_title}"> 
 
1082                   <th align=left nowrap>| . $locale->text('Department') . qq|</th>
 
1083                   <td><input id=cp_abteilung name=cp_abteilung size=30 maxlength=40 value="$form->{cp_abteilung}"> 
 
1084                   $select_department</td>
 
1087                   <th align=left nowrap>|
 
1088     . $locale->text('Given Name') . qq|</th>
 
1089                   <td><input id=cp_givenname name=cp_givenname size=30 maxlength=40 value="$form->{cp_givenname}"></td>
 
1092                   <th align=left nowrap>| . $locale->text('Name') . qq|</th>
 
1093                   <td><input id=cp_name name=cp_name size=30 maxlength=40 value="$form->{cp_name}"></td>
 
1096                   <th align=left nowrap>| . $locale->text('Phone1') . qq|</th>
 
1097                   <td><input id=cp_phone1 name=cp_phone1 size=30 maxlength=30 value="$form->{cp_phone1}"></td>
 
1100                   <th align=left nowrap>| . $locale->text('Phone2') . qq|</th>
 
1101                   <td><input id=cp_phone2 name=cp_phone2 size=30 maxlength=30 value="$form->{cp_phone2}"></td>
 
1104                   <th align=left nowrap>| . $locale->text('Fax') . qq|</th>
 
1105                   <td><input id=cp_fax name=cp_fax size=30 maxlength=30 value="$form->{cp_fax}"></td>
 
1108                   <th align=left nowrap>| . $locale->text('Mobile1') . qq|</th>
 
1109                   <td><input id=cp_mobile1 name=cp_mobile1 size=30 maxlength=30 value="$form->{cp_mobile1}"></td>
 
1112                   <th align=left nowrap>| . $locale->text('Mobile2') . qq|</th>
 
1113                   <td><input id=cp_mobile2 name=cp_mobile2 size=30 maxlength=30 value="$form->{cp_mobile2}"></td>
 
1116                   <th align=left nowrap>| . $locale->text('Sat. Phone') . qq|</th>
 
1117                   <td><input id=cp_satphone name=cp_satphone size=30 maxlength=30 value="$form->{cp_satphone}"></td>
 
1120                   <th align=left nowrap>| . $locale->text('Sat. Fax') . qq|</th>
 
1121                   <td><input id=cp_satfax name=cp_satfax size=30 maxlength=30 value="$form->{cp_satfax}"></td>
 
1124                   <th align=left nowrap>| . $locale->text('Project') . qq|</th>
 
1125                   <td><input id=cp_project name=cp_project size=30 maxlength=40 value="$form->{cp_project}"></td>
 
1128                   <th align=left nowrap>| . $locale->text('E-mail') . qq|</th>
 
1129                   <td><input id=cp_email name=cp_email size=30 maxlength=40 value="$form->{cp_email}"></td>
 
1132                   <th align=left nowrap>| . $locale->text('Private Phone') . qq|</th>
 
1133                   <td><input id=cp_privatphone name=cp_privatphone size=30 maxlength=40 value="$form->{cp_privatphone}"></td>
 
1136                   <th align=left nowrap>| . $locale->text('Private E-mail') . qq|</th>
 
1137                   <td><input id=cp_privatemail name=cp_privatemail size=30 maxlength=40 value="$form->{cp_privatemail}"></td>
 
1140                   <th align=left nowrap>| . $locale->text('Birthday') . qq|</th>
 
1141                   <td><input id=cp_birthday name=cp_birthday size=30 maxlength=40 value="$form->{cp_birthday}"></td>
 
1147         <tr height="5"></tr>|;
 
1157 <br style="clear: left" /></div>
 
1158 <div id="deliveries" class="tabcontent">
 
1162       <th align=left nowrap>| . $locale->text('From') . qq|</th>
 
1163       <td><input id=from name=from size=10 maxlength=10 value="$form->{from}">
 
1164         <input type="button" name="fromB" id="trigger_from" value="?"></td>
 
1165       <th align=left nowrap>| . $locale->text('To (time)') . qq|</th>
 
1166       <td><input id=to name=to size=10 maxlength=10 value="$form->{to}">
 
1167         <input type="button" name="toB" id="trigger_to" value="?"></td>
 
1176 <br style="clear: left" /></div>
 
1180 | . $form->write_trigger(\%myconfig, 2, "fromB", "BL", "trigger_from",
 
1181                          "toB", "BL", "trigger_to");
 
1183   $lxdebug->leave_sub();
 
1187   $lxdebug->enter_sub();
 
1189   $label     = ucfirst $form->{db};
 
1191     ($form->{db} eq 'customer')
 
1192     ? $locale->text('Save and Quotation')
 
1193     : $locale->text('Save and RFQ');
 
1195     ($form->{db} eq 'customer')
 
1196     ? $locale->text('Save and AR Transaction')
 
1197     : $locale->text('Save and AP Transaction');
 
1200       qq|<input class=submit type=submit name=action accesskey="u" value="|
 
1201       . $locale->text("Update") . qq|">|;
 
1203     $update_button = "";
 
1206 ##<input class=submit type=submit name=action value="|.$locale->text("Save and Quotation").qq|">
 
1207 ##<input class=submit type=submit name=action value="|.$locale->text("Save and RFQ").qq|">
 
1208 ##<input class=submit type=submit name=action value="|.$locale->text("Save and AR Transaction").qq|">
 
1209 ##<input class=submit type=submit name=action value="|.$locale->text("Save and AP Transaction").qq|">
 
1212 <input name=id type=hidden id=cvid value=$form->{id}>
 
1213 <input name=taxaccounts type=hidden value="$form->{taxaccounts}">
 
1214 <input name=business_save type=hidden value="$form->{selectbusiness}">
 
1215 <input name=title_save type=hidden value="$form->{title}">
 
1217 <input type=hidden name=path value=$form->{path}>
 
1218 <input type=hidden name=login value=$form->{login}>
 
1219 <input type=hidden name=password value=$form->{password}>
 
1221 <input type=hidden name=callback value="$form->{callback}">
 
1222 <input type=hidden name=db id=db value=$form->{db}>
 
1228 <input class=submit type=submit name=action accesskey="s" value="|
 
1229     . $locale->text("Save") . qq|">
 
1230 <input class=submit type=submit name=action accesskey="s" value="|
 
1231     . $locale->text("Save and Close") . qq|">
 
1232 <input class=submit type=submit name=action value="$arap">
 
1233 <input class=submit type=submit name=action value="|
 
1234     . $locale->text("Save and Invoice") . qq|">
 
1235 <input class=submit type=submit name=action value="|
 
1236     . $locale->text("Save and Order") . qq|">
 
1237 <input class=submit type=submit name=action value="$quotation">
 
1240   if ($form->{id} && $form->{status} eq 'orphaned') {
 
1241     print qq|<input class=submit type=submit name=action value="|
 
1242       . $locale->text('Delete')
 
1249 <script type="text/javascript">
 
1250 //Start Tab Content script for UL with id="maintab" Separate multiple ids each with a comma.
 
1251 initializetabcontent("maintab")
 
1257   $lxdebug->leave_sub();
 
1260 sub add_transaction {
 
1261   $lxdebug->enter_sub();
 
1263   $form->isblank("name", $locale->text("Name missing!"));
 
1264   if ($vertreter && $form->{db} eq "customer") {
 
1265     $form->isblank("salesman_id", $locale->text("Salesman missing!"));
 
1267   &{"CT::save_$form->{db}"}("", \%myconfig, \%$form);
 
1269   $form->{callback} = $form->escape($form->{callback}, 1);
 
1270   $name = $form->escape("$form->{name}", 1);
 
1273     "$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}&callback=$form->{callback}";
 
1277   $lxdebug->leave_sub();
 
1280 sub save_and_ap_transaction {
 
1281   $lxdebug->enter_sub();
 
1283   $form->{script} = "ap.pl";
 
1286   $lxdebug->leave_sub();
 
1289 sub save_and_ar_transaction {
 
1290   $lxdebug->enter_sub();
 
1292   $form->{script} = "ar.pl";
 
1295   $lxdebug->leave_sub();
 
1298 sub save_and_invoice {
 
1299   $lxdebug->enter_sub();
 
1301   $form->{script} = ($form->{db} eq 'customer') ? "is.pl" : "ir.pl";
 
1302   $form->{type} = "invoice";
 
1305   $lxdebug->leave_sub();
 
1309   $lxdebug->enter_sub();
 
1311   $form->{script} = "oe.pl";
 
1312   $form->{type}   = "request_quotation";
 
1315   $lxdebug->leave_sub();
 
1318 sub save_and_quotation {
 
1319   $lxdebug->enter_sub();
 
1321   $form->{script} = "oe.pl";
 
1322   $form->{type}   = "sales_quotation";
 
1325   $lxdebug->leave_sub();
 
1328 sub save_and_order {
 
1329   $lxdebug->enter_sub();
 
1331   $form->{script} = "oe.pl";
 
1333     ($form->{db} eq 'customer') ? "sales_order" : "purchase_order";
 
1336   $lxdebug->leave_sub();
 
1339 sub save_and_close {
 
1340   $lxdebug->enter_sub();
 
1342   # $locale->text('Customer saved!')
 
1343   # $locale->text('Vendor saved!')
 
1345   $msg = ucfirst $form->{db};
 
1348   $form->isblank("name", $locale->text("Name missing!"));
 
1349   if ($vertreter && $form->{db} eq "customer") {
 
1350     $form->isblank("salesman_id", $locale->text("Salesman missing!"));
 
1352   $rc = &{"CT::save_$form->{db}"}("", \%myconfig, \%$form);
 
1354     $form->error($locale->text('customernumber not unique!'));
 
1356   $form->redirect($locale->text($msg));
 
1358   $lxdebug->leave_sub();
 
1362   $lxdebug->enter_sub();
 
1364   # $locale->text('Customer saved!')
 
1365   # $locale->text('Vendor saved!')
 
1367   $msg = ucfirst $form->{db};
 
1370   $form->isblank("name", $locale->text("Name missing!"));
 
1371   if ($vertreter && $form->{db} eq "customer") {
 
1372     $form->isblank("salesman_id", $locale->text("Salesman missing!"));
 
1375   my $res = &{"CT::save_$form->{db}"}("", \%myconfig, \%$form);
 
1378     if ($form->{"db"} eq "customer") {
 
1379       $form->error($locale->text('This customer number is already in use.'));
 
1381       $form->error($locale->text('This vendor number is already in use.'));
 
1387   $lxdebug->leave_sub();
 
1391   $lxdebug->enter_sub();
 
1393   # $locale->text('Customer deleted!')
 
1394   # $locale->text('Cannot delete customer!')
 
1395   # $locale->text('Vendor deleted!')
 
1396   # $locale->text('Cannot delete vendor!')
 
1398   CT->delete(\%myconfig, \%$form);
 
1400   $msg = ucfirst $form->{db};
 
1401   $msg .= " deleted!";
 
1402   $form->redirect($locale->text($msg));
 
1404   $msg = "Cannot delete $form->{db}";
 
1405   $form->error($locale->text($msg));
 
1407   $lxdebug->leave_sub();
 
1411   $lxdebug->enter_sub();
 
1416   $lxdebug->leave_sub();
 
1420   $lxdebug->enter_sub();
 
1422   &check_salesman($form->{salesman});
 
1424   #  $form->get_salesman(\%myconfig, $form->{salesman});
 
1426   $lxdebug->leave_sub();
 
1429 sub check_salesman {
 
1430   $lxdebug->enter_sub();
 
1434   my ($new_name, $new_id) = split /--/, $form->{$name};
 
1437   # check name, combine name and id
 
1438   if ($form->{"oldsalesman"} ne $form->{"salesman"}) {
 
1440     # return one name or a list of names in $form->{name_list}
 
1441     if (($i = $form->get_salesman(\%myconfig, $name)) > 1) {
 
1442       &select_salesman($name);
 
1449       $form->{"salesman_id"} = $form->{salesman_list}[0]->{id};
 
1450       $form->{salesman}      = $form->{salesman_list}[0]->{name};
 
1451       $form->{"oldsalesman"} = $form->{salesman};
 
1455       # name is not on file
 
1456       # $locale->text('Customer not on file!')
 
1457       # $locale->text('Vendor not on file!')
 
1458       $msg = ucfirst $name . " not on file or locked!";
 
1459       $form->error($locale->text($msg));
 
1463   $lxdebug->leave_sub();
 
1468 sub select_salesman {
 
1469   $lxdebug->enter_sub();
 
1473   @column_index = qw(ndx name);
 
1475   $label             = ucfirst $table;
 
1476   $column_data{ndx}  = qq|<th> </th>|;
 
1477   $column_data{name} =
 
1478     qq|<th class=listheading>| . $locale->text($label) . qq|</th>|;
 
1480   # list items with radio button on a form
 
1483   $title = $locale->text('Select from one of the names below');
 
1488 <form method=post action=$form->{script}>
 
1492     <th class=listtop>$title</th>
 
1498         <tr class=listheading>|;
 
1500   map { print "\n$column_data{$_}" } @column_index;
 
1507   foreach $ref (@{ $form->{salesman_list} }) {
 
1508     $checked = ($i++) ? "" : "checked";
 
1510     $ref->{name} =~ s/\"/"/g;
 
1513       qq|<td><input name=ndx class=radio type=radio value=$i $checked></td>|;
 
1514     $column_data{name} =
 
1515       qq|<td><input name="new_name_$i" type=hidden value="$ref->{name}">$ref->{name}</td>|;
 
1520         <tr class=listrow$j>|;
 
1522     map { print "\n$column_data{$_}" } @column_index;
 
1527 <input name="new_id_$i" type=hidden value=$ref->{id}>
 
1538     <td><hr size=3 noshade></td>
 
1542 <input name=lastndx type=hidden value=$i>
 
1547   map { delete $form->{$_} } qw(action name_list header);
 
1549   # save all other form variables
 
1550   foreach $key (keys %${form}) {
 
1551     $form->{$key} =~ s/\"/"/g;
 
1552     print qq|<input name=$key type=hidden value="$form->{$key}">\n|;
 
1556 <input type=hidden name=nextsub value=salesman_selected>
 
1558 <input type=hidden name=vc value=$table>
 
1560 <input class=submit type=submit name=action value="|
 
1561     . $locale->text('Continue') . qq|">
 
1568   $lxdebug->leave_sub();
 
1571 sub salesman_selected {
 
1572   $lxdebug->enter_sub();
 
1574   # replace the variable with the one checked
 
1576   # index for new item
 
1579   $form->{salesman}      = $form->{"new_name_$i"};
 
1580   $form->{"salesman_id"} = $form->{"new_id_$i"};
 
1581   $form->{"oldsalesman"} = $form->{salesman};
 
1583   # delete all the new_ variables
 
1584   for $i (1 .. $form->{lastndx}) {
 
1585     map { delete $form->{"new_${_}_$i"} } (id, name);
 
1588   map { delete $form->{$_} } qw(ndx lastndx nextsub);
 
1592   $lxdebug->leave_sub();
 
1596   $lxdebug->enter_sub();
 
1598   CT->get_contact(\%myconfig, \%$form);
 
1601   $result = "$form->{cp_name}";
 
1602   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);
 
1605   $lxdebug->leave_sub();
 
1611   $lxdebug->enter_sub();
 
1613   CT->get_shipto(\%myconfig, \%$form);
 
1616   $result = "$form->{shiptoname}";
 
1617   map { $result .= "__pjx__" . $form->{$_} } qw(shiptodepartment_1 shiptodepartment_2 shiptostreet shiptozipcode shiptocity shiptocountry shiptocontact shiptophone shiptofax shiptoemail);
 
1620   $lxdebug->leave_sub();
 
1625   $lxdebug->enter_sub();
 
1627   CT->get_delivery(\%myconfig, \%$form );
 
1630     $form->sort_columns(shiptoname,
 
1640   $column_header{shiptoname} =
 
1641     qq|<th class=listheading>| . $locale->text('Shipping Address') . qq|</th>|;
 
1642   $column_header{invnumber} =
 
1643       qq|<th class=listheading>|. $locale->text('Invoice'). qq|</th>|;
 
1644   $column_header{ordnumber} =
 
1645       qq|<th class=listheading>|. $locale->text('Order'). qq|</th>|;
 
1646   $column_header{transdate} =
 
1647     qq|<th class=listheading>| . $locale->text('Invdate') . qq|</th>|;
 
1648   $column_header{description} =
 
1649     qq|<th class=listheading>| . $locale->text('Description') . qq|</th>|;
 
1650   $column_header{qty} =
 
1651     qq|<th class=listheading>| . $locale->text('Qty') . qq|</th>|;
 
1652   $column_header{unit} =
 
1653     qq|<th class=listheading>| . $locale->text('Unit') . qq|</th>|;
 
1660         <tr class=listheading>
 
1663   map { $result .= "$column_header{$_}\n" } @column_index;
 
1670   foreach $ref (@{ $form->{DELIVERY} }) {
 
1672     if ($ref->{shiptoname} eq $sameshiptoname) {
 
1673       map { $column_data{$_} = "<td>$ref->{$_} </td>" } @column_index;
 
1674       $column_data{shiptoname} = "<td> </td>";
 
1676       map { $column_data{$_} = "<td>$ref->{$_} </td>" } @column_index;
 
1682         <tr class=listrow$i>
 
1685     map { $result .= "$column_data{$_}\n" } @column_index;
 
1691     $sameshiptoname = $ref->{shiptoname};
 
1703   $lxdebug->leave_sub();
 
1707 sub continue { &{ $form->{nextsub} } }