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')
 
  42 use POSIX qw(strftime);
 
  45 use SL::ReportGenerator;
 
  47 require "bin/mozilla/common.pl";
 
  48 require "bin/mozilla/reportgenerator.pl";
 
  55   $lxdebug->enter_sub();
 
  57   $form->{title} = "Add";
 
  60     "$form->{script}?action=add&db=$form->{db}&login=$form->{login}&password=$form->{password}"
 
  61     unless $form->{callback};
 
  63   CT->populate_drop_down_boxes(\%myconfig, \%$form);
 
  68   $lxdebug->leave_sub();
 
  72   $lxdebug->enter_sub();
 
  74   $form->{IS_CUSTOMER} = $form->{db} eq 'customer';
 
  76   $form->get_lists("business_types" => "ALL_BUSINESS_TYPES");
 
  77   $form->{SHOW_BUSINESS_TYPES} = scalar @{ $form->{ALL_BUSINESS_TYPES} } > 0;
 
  79   $form->{title} = $form->{IS_CUSTOMER} ? $locale->text('Customers') : $locale->text('Vendors');
 
  80   $form->{fokus} = 'Form.name';
 
  83   print $form->parse_html_template2('ct/search');
 
  85   $lxdebug->leave_sub();
 
  89   $lxdebug->enter_sub();
 
  91   $form->{IS_CUSTOMER} = $form->{db} eq 'customer';
 
  93   CT->search(\%myconfig, \%$form);
 
  96   if ($form->{status} eq 'all') {
 
  97     push @options, $locale->text('All');
 
  99   } elsif ($form->{status} eq 'orphaned') {
 
 100     push @options, $locale->text('Orphaned');
 
 104     push @options, $locale->text('Name') . " : $form->{name}";
 
 106   if ($form->{contact}) {
 
 107     push @options, $locale->text('Contact') . " : $form->{contact}";
 
 109   if ($form->{"$form->{db}number"}) {
 
 110     push @options, $locale->text('Number') . qq| : $form->{"$form->{db}number"}|;
 
 112   if ($form->{email}) {
 
 113     push @options, $locale->text('E-mail') . " : $form->{email}";
 
 117     'id',        'name',  "$form->{db}number", 'address',  'contact',  'phone',
 
 118     'fax',       'email', 'taxnumber',         'sic_code', 'business', 'invnumber',
 
 119     'ordnumber', 'quonumber'
 
 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'), },
 
 140   map { $column_defs{$_}->{visible} = $form->{"l_$_"} eq 'Y' } @columns;
 
 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});
 
 147   map { $column_defs{$_}->{link} = "${callback}&sort=${_}" } @columns;
 
 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');
 
 157     $form->{title}       = $locale->text('Vendors');
 
 158     $ordertype           = 'purchase_order';
 
 159     $quotationtype       = 'request_quotation';
 
 160     $attachment_basename = $locale->text('vendor_list');
 
 163   my $report = SL::ReportGenerator->new(\%myconfig, $form);
 
 165   $report->set_options('top_info_text'         => join("\n", @options),
 
 166                        'raw_bottom_info_text'  => $form->parse_html_template2('ct/list_names_bottom'),
 
 167                        'output_format'         => 'HTML',
 
 168                        'title'                 => $form->{title},
 
 169                        'attachment_basename'   => $attachment_basename . strftime('_%Y%m%d', localtime time),
 
 171   $report->set_options_from_form();
 
 173   $report->set_columns(%column_defs);
 
 174   $report->set_column_order(@columns);
 
 176   $report->set_export_options('list_names', @hidden_variables);
 
 178   $report->set_sort_indicator($form->{sort}, 1);
 
 182   foreach my $ref (@{ $form->{CT} }) {
 
 183     my $row = { map { $_ => { 'data' => '' } } @columns };
 
 185     if ($ref->{id} ne $previous_id) {
 
 186       $previous_id = $ref->{id};
 
 187       map { $row->{$_}->{data} = $ref->{$_} } @columns;
 
 189       $row->{name}->{link}  = build_std_url('action=edit', 'id=' . E($ref->{id}), 'callback', @hidden_nondefault);
 
 190       $row->{email}->{link} = 'mailto:' . E($ref->{email});
 
 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};
 
 200     $report->add_data($row);
 
 203   $report->generate_with_headers();
 
 205   $lxdebug->leave_sub();
 
 209   $lxdebug->enter_sub();
 
 211   # show history button
 
 212   $form->{javascript} = qq|<script type=text/javascript src=js/show_history.js></script>|;
 
 213   #/show hhistory button
 
 215   # $locale->text('Edit Customer')
 
 216   # $locale->text('Edit Vendor')
 
 218   CT->get_tuple(\%myconfig, \%$form);
 
 219   CT->populate_drop_down_boxes(\%myconfig, \%$form);
 
 221   # format " into "
 
 222   map { $form->{$_} =~ s/\"/"/g } keys %$form;
 
 224   $form->{title} = "Edit";
 
 227   $form->{discount} *= 100;
 
 232   $lxdebug->leave_sub();
 
 236   $lxdebug->enter_sub();
 
 238   $form->get_lists("employees" => "ALL_SALESMEN",
 
 239                    "taxzones" => "ALL_TAXZONES");
 
 241   $form->{taxincluded} = ($form->{taxincluded}) ? "checked" : "";
 
 242   $form->{creditlimit} =
 
 243     $form->format_amount(\%myconfig, $form->{creditlimit}, 0);
 
 244   $form->{discount} = $form->format_amount(\%myconfig, $form->{discount});
 
 246   if ($myconfig{role} eq 'admin') {
 
 249           <th align=right nowrap>| . $locale->text('Bcc') . qq|</th>
 
 250           <td><input name=bcc size=35 value="$form->{bcc}"></td>
 
 254   $form->{obsolete} = "checked" if $form->{obsolete};
 
 256   $lang = qq|<option value=""></option>|;
 
 257   foreach $item (@{ $form->{languages} }) {
 
 258     if ($form->{language_id} eq $item->{id}) {
 
 259       $lang .= qq|<option value="$item->{id}" selected>$item->{description}</option>|;
 
 261       $lang .= qq|<option value="$item->{id}">$item->{description}</option>|;
 
 265   $payment = qq|<option value=""></option>|;
 
 266   foreach $item (@{ $form->{payment_terms} }) {
 
 267     if ($form->{payment_id} eq $item->{id}) {
 
 268       $payment .= qq|<option value="$item->{id}" selected>$item->{description}</option>|;
 
 270       $payment .= qq|<option value="$item->{id}">$item->{description}</option>|;
 
 275     if ($form->{db} eq "customer") {
 
 276       $form->{taxzone_id} = 0;
 
 278       $form->{taxzone_id} = 0;
 
 284   foreach my $item (@{ $form->{"ALL_TAXZONES"} }) {
 
 285     push(@values, $item->{"id"});
 
 286     $labels{$item->{"id"}} = $item->{"description"};
 
 290                 <th align=right>| . $locale->text('Steuersatz') . qq|</th>
 
 292         NTI($cgi->popup_menu('-name' => 'taxzone_id', '-default' => $form->{"taxzone_id"},
 
 293                              '-values' => \@values, '-labels' => \%labels)) . qq|
 
 298     "$form->{script}?login=$form->{login}&password=$form->{password}&action=get_contact";
 
 300   my $pjx = new CGI::Ajax( 'get_contact' => $get_contact_url );
 
 301   $form->{selectcontact} = "<option value=0>" . $locale->text('New contact') . "</option>";
 
 302   if (@{ $form->{CONTACTS} }) {
 
 303     foreach $item (@{ $form->{CONTACTS} }) {
 
 304       if ($item->{cp_id} == $form->{cp_id}) {
 
 305         $form->{selectcontact} .=
 
 306           qq|<option value=$item->{cp_id} selected>$item->{cp_name}</option>\n|;
 
 308         $form->{selectcontact} .=
 
 309           qq|<option value=$item->{cp_id}>$item->{cp_name}</option>\n|;
 
 314   push(@ { $form->{AJAX} }, $pjx);
 
 315   $ansprechpartner = qq|
 
 317                 <th align=right>| . $locale->text('Ansprechpartner') . qq|</th>
 
 318                 <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>
 
 319                 <input type=hidden name=selectcontact value="$form->{selectcontact}">
 
 322     "$form->{script}?login=$form->{login}&password=$form->{password}&action=get_shipto";
 
 324   my $pjy = new CGI::Ajax( 'get_shipto' => $get_shipto_url );
 
 325   $form->{selectshipto} = "<option value=0></option>";
 
 326   $form->{selectshipto} .= "<option value=0>Alle</option>";
 
 327   if (@{ $form->{SHIPTO} }) {
 
 328     foreach $item (@{ $form->{SHIPTO} }) {
 
 329       if ($item->{shipto_id} == $form->{shipto_id}) {
 
 330         $form->{selectshipto} .=
 
 331           "<option value=$item->{shipto_id} selected>$item->{shiptoname} $item->{shiptodepartment_1}\n";
 
 333         $form->{selectshipto} .=
 
 334           "<option value=$item->{shipto_id}>$item->{shiptoname} $item->{shiptodepartment_1}\n";
 
 339   push(@ { $form->{AJAX} }, $pjy);
 
 343                 <th align=right>| . $locale->text('Shipping Address') . qq|</th>
 
 344                 <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>
 
 345                 <input type=hidden name=selectshipto value="$form->{selectshipto}">
 
 350     "$form->{script}?login=$form->{login}&password=$form->{password}&action=get_delivery";
 
 352   my $pjz = new CGI::Ajax( 'get_delivery' => $get_delivery_url );
 
 354   push(@ { $form->{AJAX} }, $pjz);
 
 358                 <th align=right>| . $locale->text('Shipping Address') . qq|</th>
 
 359                 <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>
 
 362   $form->{selectbusiness} = qq|<option>\n|;
 
 364     $form->{selectbusiness} .=
 
 365       qq|<option value=$_->{id}>$_->{description}\n|
 
 366   } @{ $form->{all_business} };
 
 367   if ($form->{business_save}) {
 
 368     $form->{selectbusiness} = $form->{business_save};
 
 370   $form->{selectbusiness} =~
 
 371     s/<option value=$form->{business}>/<option value=$form->{business} selected>/;
 
 373   $label = ucfirst $form->{db};
 
 374   if ($form->{title} eq "Edit") {
 
 375     $form->{title} = $locale->text("$form->{title} $label") . " $form->{name}";
 
 377     $form->{title} = $locale->text("$form->{title} $label");
 
 379   if ($form->{title_save}) {
 
 380     $form->{title} = $form->{title_save};
 
 382   if ($form->{db} eq 'vendor') {
 
 384            <th align=right>| . $locale->text('Kundennummer') . qq|</th>
 
 385            <td><input name=v_customer_id size=10 value="$form->{v_customer_id}"></td>
 
 389   if ($form->{db} eq 'customer') {
 
 392            <th align=right>| . $locale->text('KNr. beim Kunden') . qq|</th>
 
 393            <td><input name=c_vendor_id size=10 value="$form->{c_vendor_id}"></td>
 
 398           <th align=right>| . $locale->text('Type of Business') . qq|</th>
 
 399           <td><select name=business>$form->{selectbusiness}</select></td>
 
 404   if ($form->{db} eq "customer") {
 
 405     my (@salesman_values, %salesman_labels);
 
 406     push(@salesman_values, undef);
 
 407     foreach my $item (@{ $form->{ALL_SALESMEN} }) {
 
 408       push(@salesman_values, $item->{id});
 
 409       $salesman_labels{$item->{id}} = $item->{name} ne "" ? $item->{name} : $item->{login};
 
 413       qq| <th align="right">| . $locale->text('Salesman') . qq|</th>
 
 415       NTI($cgi->popup_menu('-name' => 'salesman_id', '-default' => $form->{salesman_id},
 
 416                            '-values' => \@salesman_values, '-labels' => \%salesman_labels))
 
 420 ## LINET: Create a drop-down box with all prior titles and greetings.
 
 421   CT->query_titles_and_greetings(\%myconfig, \%$form);
 
 423   $select_title = qq| <select name=selected_cp_title><option></option>|;
 
 424   map({ $select_title .= qq|<option>$_</option>|; } @{ $form->{TITLES} });
 
 425   $select_title .= qq|</select>|;
 
 428     qq| <select name=selected_cp_greeting><option></option>|;
 
 430      { $select_greeting .= qq|<option>$_</option>|; } @{ $form->{GREETINGS} });
 
 431   $select_greeting .= qq|</select>|;
 
 433   $select_company_greeting =
 
 434     qq| <select name=selected_company_greeting><option></option>|;
 
 436      { $select_company_greeting .= qq|<option>$_</option>|; } @{ $form->{COMPANY_GREETINGS} });
 
 437   $select_company_greeting .= qq|</select>|;
 
 440     qq| <select name=selected_cp_abteilung><option></option>|;
 
 442      { $select_department .= qq|<option>$_</option>|; } @{ $form->{DEPARTMENT} });
 
 443   $select_department .= qq|</select>|;
 
 446   if ($form->{db} eq 'customer') {
 
 448     #get pricegroup and form it
 
 449     $form->get_pricegroup(\%myconfig, { all => 1 });
 
 451     $form->{pricegroup}    = "$form->{klass}";
 
 452     $form->{pricegroup_id} = "$form->{klass}";
 
 454     if (@{ $form->{all_pricegroup} }) {
 
 456       $form->{selectpricegroup} = qq|<option>\n|;
 
 458         $form->{selectpricegroup} .=
 
 459           qq|<option value="$_->{id}">$_->{pricegroup}\n|
 
 460       } @{ $form->{all_pricegroup} };
 
 463     if ($form->{selectpricegroup}) {
 
 464       $form->{selectpricegroup} = $form->unescape($form->{selectpricegroup});
 
 467         qq|<input type=hidden name=selectpricegroup value="|
 
 468         . $form->escape($form->{selectpricegroup}, 1) . qq|">|;
 
 470       $form->{selectpricegroup} =~
 
 471         s/(<option value="\Q$form->{klass}\E")/$1 selected/;
 
 474         qq|<select name=klass>$form->{selectpricegroup}</select>|;
 
 479   # $locale->text('Customer Number')
 
 480   # $locale->text('Vendor Number')
 
 481   $form->{fokus} = "ct.greeting";
 
 482   $form->{jsscript} = 1;
 
 486 <body onLoad="fokus()">
 
 489     <th class=listtop>$form->{title}</th>
 
 494 <form method=post name="ct" action=$form->{script} onKeyUp="highlight(event)" onClick="highlight(event)">
 
 498 <ul id="maintab" class="shadetabs">
 
 499 <li class="selected"><a href="#" rel="billing">|
 
 500     . $locale->text('Billing Address') . qq|</a></li>
 
 501 <li><a href="#" rel="shipto">|
 
 502     . $locale->text('Shipping Address') . qq|</a></li>
 
 503 <li><a href="#" rel="contacts">Ansprechpartner</a></li>
 
 504 <li><a href="#" rel="deliveries">|
 
 505     . $locale->text('Lieferungen') . qq|</a></li>
 
 509 <div class="tabcontentstyle">
 
 511 <div id="billing" class="tabcontent">
 
 516           <th align=right nowrap>| . $locale->text($label . ' Number') . qq|</th>
 
 517           <td><input name="$form->{db}number" size=35 value="$form->{"$form->{db}number"}"></td>
 
 520           <th align=right nowrap>| . $locale->text('Greeting') . qq|</th>
 
 521           <td><input id=greeting name=greeting size=30 value="$form->{greeting}"> 
 
 522           $select_company_greeting</td>
 
 525           <th align=right nowrap>| . $locale->text('Company Name') . qq|</th>
 
 526           <td><input name=name size=35 maxlength=75 value="$form->{name}"></td>
 
 529           <th align=right nowrap>| . $locale->text('Abteilung') . qq|</th>
 
 530           <td><input name=department_1 size=16 maxlength=75 value="$form->{department_1}">
 
 531           <input name=department_2 size=16 maxlength=75 value="$form->{department_2}"></td>
 
 534           <th align=right nowrap>| . $locale->text('Street') . qq|</th>
 
 535           <td><input name=street size=35 maxlength=75 value="$form->{street}"></td>
 
 538           <th align=right nowrap>|
 
 539     . $locale->text('Zipcode') . "/" . $locale->text('City') . qq|</th>
 
 540           <td><input name=zipcode size=5 maxlength=10 value="$form->{zipcode}">
 
 541           <input name=city size=30 maxlength=75 value="$form->{city}"></td>
 
 544           <th align=right nowrap>| . $locale->text('Country') . qq|</th>
 
 545           <td><input name=country size=35 maxlength=75 value="$form->{country}"></td>
 
 548           <th align=right nowrap>| . $locale->text('Contact') . qq|</th>
 
 549           <td><input name=contact size=28 maxlength=75 value="$form->{contact}"></td>
 
 552           <th align=right nowrap>| . $locale->text('Phone') . qq|</th>
 
 553           <td><input name=phone size=30 maxlength=30 value="$form->{phone}"></td>
 
 556           <th align=right nowrap>| . $locale->text('Fax') . qq|</th>
 
 557           <td><input name=fax size=30 maxlength=30 value="$form->{fax}"></td>
 
 560           <th align=right nowrap>| . $locale->text('E-mail') . qq|</th>
 
 561           <td><input name=email size=45 value="$form->{email}"></td>
 
 564           <th align=right nowrap>| . $locale->text('Homepage') . qq|</th>
 
 565           <td><input name=homepage size=45 value="$form->{homepage}"></td>
 
 570           <th align=right>| . $locale->text('Credit Limit') . qq|</th>
 
 571           <td><input name=creditlimit size=9 value="$form->{creditlimit}"></td>
 
 572           <input type="hidden" name="terms" value="$form->{terms}">
 
 573           <th align=right>| . $locale->text('Payment Terms') . qq|</th>
 
 574           <td><select name=payment_id>$payment</select></td>
 
 575           <th align=right>| . $locale->text('Discount') . qq|</th>
 
 576           <td><input name=discount size=4 value="$form->{discount}">
 
 580           <th align=right>| . $locale->text('Tax Number / SSN') . qq|</th>
 
 581           <td><input name=taxnumber size=20 value="$form->{taxnumber}"></td>
 
 582           <th align=right>| . $locale->text('USt-IdNr.') . qq|</th>
 
 583           <td><input name="ustid" maxlength="14" size="20" value="$form->{ustid}"></td>
 
 587           <th align=right>| . $locale->text('Account Number') . qq|</th>
 
 588           <td><input name="account_number" size="10" maxlength="15" value="$form->{account_number}"></td>
 
 589           <th align=right>| . $locale->text('Bank Code Number') . qq|</th>
 
 590           <td><input name="bank_code" size="10" maxlength="10" value="$form->{bank_code}"></td>
 
 591           <th align=right>| . $locale->text('Bank') . qq|</th>
 
 592           <td><input name=bank size=30 value="$form->{bank}"></td>
 
 596           <th align=right>| . $locale->text('Language') . qq|</th>
 
 597           <td><select name=language_id>$lang
 
 600   if ($form->{db} eq 'customer') {
 
 603           <th align=right>| . $locale->text('Preisklasse') . qq|</th>
 
 604           <td>$pricegroup</td>|;
 
 608           <td align=right>| . $locale->text('Obsolete') . qq|</td>
 
 609           <td><input name=obsolete class=checkbox type=checkbox value=1 $form->{obsolete}></td>
 
 618     <th align=left nowrap>| . $locale->text('Notes') . qq|</th>
 
 621     <td><textarea name=notes rows=3 cols=60 wrap=soft>$form->{notes}</textarea></td>
 
 628 <br style="clear: left" /></div>|;
 
 631       <div id="shipto" class="tabcontent">
 
 636           <th align=right nowrap>| . $locale->text('Company Name') . qq|</th>
 
 637           <td><input id=shiptoname name=shiptoname size=35 maxlength=75 value="$form->{shiptoname}"></td>
 
 640           <th align=right nowrap>| . $locale->text('Abteilung') . qq|</th>
 
 641           <td><input id=shiptodepartment_1 name=shiptodepartment_1 size=16 maxlength=75 value="$form->{shiptodepartment_1}">
 
 642           <input id=shiptodepartment_2 name=shiptodepartment_2 size=16 maxlength=75 value="$form->{shiptodepartment_2}"></td>
 
 645           <th align=right nowrap>| . $locale->text('Street') . qq|</th>
 
 646           <td><input id=shiptostreet name=shiptostreet size=35 maxlength=75 value="$form->{shiptostreet}"></td>
 
 649           <th align=right nowrap>|
 
 650     . $locale->text('Zipcode') . "/" . $locale->text('City') . qq|</th>
 
 651           <td><input id=shiptozipcode name=shiptozipcode size=5 maxlength=75 value="$form->{shiptozipcode}">
 
 652           <input id=shiptocity name=shiptocity size=30 maxlength=75 value="$form->{shiptocity}"></td>
 
 655           <th align=right nowrap>| . $locale->text('Country') . qq|</th>
 
 656           <td><input id=shiptocountry name=shiptocountry size=35 maxlength=75 value="$form->{shiptocountry}"></td>
 
 659           <th align=right nowrap>| . $locale->text('Contact') . qq|</th>
 
 660           <td><input id=shiptocontact name=shiptocontact size=30 maxlength=75 value="$form->{shiptocontact}"></td>
 
 663           <th align=right nowrap>| . $locale->text('Phone') . qq|</th>
 
 664           <td><input id=shiptophone name=shiptophone size=30 maxlength=30 value="$form->{shiptophone}"></td>
 
 667           <th align=right nowrap>| . $locale->text('Fax') . qq|</th>
 
 668           <td><input id=shiptofax name=shiptofax size=30 maxlength=30 value="$form->{shiptofax}"></td>
 
 671           <th align=right nowrap>| . $locale->text('E-mail') . qq|</th>
 
 672           <td><input id=shiptoemail name=shiptoemail size=45 value="$form->{shiptoemail}"></td>
 
 682 <br style="clear: left" /></div>|;
 
 685 ##LINET - added fields for contact person
 
 687 <div id="contacts" class="tabcontent">
 
 691                 <input type=hidden name=cp_id value=$form->{cp_id}>
 
 695                   <th align=left nowrap>| . $locale->text('Greeting') . qq|</th>
 
 696                   <td><input id=cp_greeting name=cp_greeting size=40 maxlength=75 value="$form->{cp_greeting}"> 
 
 697                   $select_greeting</td>
 
 700                   <th align=left nowrap>| . $locale->text('Title') . qq|</th>
 
 701                   <td><input id=cp_title name=cp_title size=40 maxlength=75 value="$form->{cp_title}"> 
 
 705                   <th align=left nowrap>| . $locale->text('Department') . qq|</th>
 
 706                   <td><input id=cp_abteilung name=cp_abteilung size=40 value="$form->{cp_abteilung}"> 
 
 707                   $select_department</td>
 
 710                   <th align=left nowrap>|
 
 711     . $locale->text('Given Name') . qq|</th>
 
 712                   <td><input id="cp_givenname" name="cp_givenname" size="40" maxlength="75" value="$form->{cp_givenname}"></td>
 
 715                   <th align=left nowrap>| . $locale->text('Name') . qq|</th>
 
 716                   <td><input id="cp_name" name="cp_name" size="40" maxlength="75" value="$form->{cp_name}"></td>
 
 719                   <th align=left nowrap>| . $locale->text('Phone1') . qq|</th>
 
 720                   <td><input id="cp_phone1" name="cp_phone1" size="40" maxlength="75" value="$form->{cp_phone1}"></td>
 
 723                   <th align=left nowrap>| . $locale->text('Phone2') . qq|</th>
 
 724                   <td><input id="cp_phone2" name="cp_phone2" size="40" maxlength="75" value="$form->{cp_phone2}"></td>
 
 727                   <th align=left nowrap>| . $locale->text('Fax') . qq|</th>
 
 728                   <td><input id=cp_fax name=cp_fax size=40 value="$form->{cp_fax}"></td>
 
 731                   <th align=left nowrap>| . $locale->text('Mobile1') . qq|</th>
 
 732                   <td><input id=cp_mobile1 name=cp_mobile1 size=40 value="$form->{cp_mobile1}"></td>
 
 735                   <th align=left nowrap>| . $locale->text('Mobile2') . qq|</th>
 
 736                   <td><input id=cp_mobile2 name=cp_mobile2 size=40 value="$form->{cp_mobile2}"></td>
 
 739                   <th align=left nowrap>| . $locale->text('Sat. Phone') . qq|</th>
 
 740                   <td><input id=cp_satphone name=cp_satphone size=40 value="$form->{cp_satphone}"></td>
 
 743                   <th align=left nowrap>| . $locale->text('Sat. Fax') . qq|</th>
 
 744                   <td><input id=cp_satfax name=cp_satfax size=40 value="$form->{cp_satfax}"></td>
 
 747                   <th align=left nowrap>| . $locale->text('Project') . qq|</th>
 
 748                   <td><input id=cp_project name=cp_project size=40 value="$form->{cp_project}"></td>
 
 751                   <th align=left nowrap>| . $locale->text('E-mail') . qq|</th>
 
 752                   <td><input id=cp_email name=cp_email size=40 value="$form->{cp_email}"></td>
 
 755                   <th align=left nowrap>| . $locale->text('Private Phone') . qq|</th>
 
 756                   <td><input id=cp_privatphone name=cp_privatphone size=40 value="$form->{cp_privatphone}"></td>
 
 759                   <th align=left nowrap>| . $locale->text('Private E-mail') . qq|</th>
 
 760                   <td><input id=cp_privatemail name=cp_privatemail size=40 value="$form->{cp_privatemail}"></td>
 
 763                   <th align=left nowrap>| . $locale->text('Birthday') . qq|</th>
 
 764                   <td><input id=cp_birthday name=cp_birthday size=40 value="$form->{cp_birthday}"></td>
 
 770         <tr height="5"></tr>|;
 
 780 <br style="clear: left" /></div>
 
 781 <div id="deliveries" class="tabcontent">
 
 785       <th align=left nowrap>| . $locale->text('From') . qq|</th>
 
 786       <td><input id=from name=from size=10 maxlength=10 value="$form->{from}">
 
 787         <input type="button" name="fromB" id="trigger_from" value="?"></td>
 
 788       <th align=left nowrap>| . $locale->text('To (time)') . qq|</th>
 
 789       <td><input id=to name=to size=10 maxlength=10 value="$form->{to}">
 
 790         <input type="button" name="toB" id="trigger_to" value="?"></td>
 
 799 <br style="clear: left" /></div>
 
 803 | . $form->write_trigger(\%myconfig, 2, "fromB", "BL", "trigger_from",
 
 804                          "toB", "BL", "trigger_to");
 
 806   $lxdebug->leave_sub();
 
 810   $lxdebug->enter_sub();
 
 812   $label     = ucfirst $form->{db};
 
 814     ($form->{db} eq 'customer')
 
 815     ? $locale->text('Save and Quotation')
 
 816     : $locale->text('Save and RFQ');
 
 818     ($form->{db} eq 'customer')
 
 819     ? $locale->text('Save and AR Transaction')
 
 820     : $locale->text('Save and AP Transaction');
 
 822 ##<input class=submit type=submit name=action value="|.$locale->text("Save and Quotation").qq|">
 
 823 ##<input class=submit type=submit name=action value="|.$locale->text("Save and RFQ").qq|">
 
 824 ##<input class=submit type=submit name=action value="|.$locale->text("Save and AR Transaction").qq|">
 
 825 ##<input class=submit type=submit name=action value="|.$locale->text("Save and AP Transaction").qq|">
 
 828 <input name=id type=hidden id=cvid value=$form->{id}>
 
 829 <input name=business_save type=hidden value="$form->{selectbusiness}">
 
 830 <input name=title_save type=hidden value="$form->{title}">
 
 832 <input type=hidden name=login value=$form->{login}>
 
 833 <input type=hidden name=password value=$form->{password}>
 
 835 <input type=hidden name=callback value="$form->{callback}">
 
 836 <input type=hidden name=db id=db value=$form->{db}>
 
 841 <input class=submit type=submit name=action accesskey="s" value="|
 
 842     . $locale->text("Save") . qq|">
 
 843 <input class=submit type=submit name=action accesskey="s" value="|
 
 844     . $locale->text("Save and Close") . qq|">
 
 845 <input class=submit type=submit name=action value="$arap">
 
 846 <input class=submit type=submit name=action value="|
 
 847     . $locale->text("Save and Invoice") . qq|">
 
 848 <input class=submit type=submit name=action value="|
 
 849     . $locale->text("Save and Order") . qq|">
 
 850 <input class=submit type=submit name=action value="$quotation">
 
 853   if ($form->{id} && $form->{status} eq 'orphaned') {
 
 854     print qq|<input class=submit type=submit name=action value="|
 
 855       . $locale->text('Delete')
 
 859   # button for saving history
 
 860   if($form->{id} ne "") {
 
 862           <input type=button class=submit onclick=set_history_window(|
 
 864           . qq|); name=history id=history value=|
 
 865           . $locale->text('history') 
 
 868   # /button for saving history
 
 873 <script type="text/javascript">
 
 874 //Start Tab Content script for UL with id="maintab" Separate multiple ids each with a comma.
 
 875 initializetabcontent("maintab")
 
 881   $lxdebug->leave_sub();
 
 884 sub add_transaction {
 
 885   $lxdebug->enter_sub();
 
 887 #  # saving the history
 
 888 #  if(!exists $form->{addition}) {
 
 889 #       $form->{addition} = "ADD TRANSACTION";
 
 890 #       $form->save_history($form->dbconnect(\%myconfig));
 
 892 #  # /saving the history
 
 894   $form->isblank("name", $locale->text("Name missing!"));
 
 895   if ($form->{"db"} eq "customer") {
 
 896     CT->save_customer(\%myconfig, \%$form);
 
 898     CT->save_vendor(\%myconfig, \%$form);
 
 901   $form->{callback} = $form->escape($form->{callback}, 1);
 
 902   $name = $form->escape("$form->{name}", 1);
 
 905     "$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}";
 
 908   $lxdebug->leave_sub();
 
 911 sub save_and_ap_transaction {
 
 912   $lxdebug->enter_sub();
 
 914   $form->{script} = "ap.pl";
 
 916   if(!exists $form->{addition}) {
 
 917     $form->{snumbers} = qq|invnumber_| . $form->{invnumber};
 
 918         $form->{addition} = "SAVED";
 
 919         $form->save_history($form->dbconnect(\%myconfig));
 
 921   # /saving the history
 
 923   $lxdebug->leave_sub();
 
 926 sub save_and_ar_transaction {
 
 927   $lxdebug->enter_sub();
 
 929   $form->{script} = "ar.pl";
 
 931   if(!exists $form->{addition}) {
 
 932     $form->{snumbers} = qq|invnumber_| . $form->{invnumber};
 
 933         $form->{addition} = "SAVED";
 
 934         $form->save_history($form->dbconnect(\%myconfig));
 
 936   # /saving the history
 
 938   $lxdebug->leave_sub();
 
 941 sub save_and_invoice {
 
 942   $lxdebug->enter_sub();
 
 944   $form->{script} = ($form->{db} eq 'customer') ? "is.pl" : "ir.pl";
 
 945   $form->{type} = "invoice";
 
 947   if(!exists $form->{addition}) {
 
 948     $form->{snumbers} = qq|invnumber_| . $form->{invnumber};
 
 949         $form->{addition} = "SAVED";
 
 950         $form->save_history($form->dbconnect(\%myconfig));
 
 952   # /saving the history
 
 954   $lxdebug->leave_sub();
 
 958   $lxdebug->enter_sub();
 
 960   $form->{script} = "oe.pl";
 
 961   $form->{type}   = "request_quotation";
 
 963   if(!exists $form->{addition}) {
 
 964     $form->{snumbers} = qq|ordnumber_| . $form->{ordnumber};
 
 965         $form->{addition} = "SAVED";
 
 966         $form->save_history($form->dbconnect(\%myconfig));
 
 968   # /saving the history
 
 970   $lxdebug->leave_sub();
 
 973 sub save_and_quotation {
 
 974   $lxdebug->enter_sub();
 
 976   $form->{script} = "oe.pl";
 
 977   $form->{type}   = "sales_quotation";
 
 979   if(!exists $form->{addition}) {
 
 980     $form->{snumbers} = qq|ordnumber_| . $form->{ordnumber};
 
 981         $form->{addition} = "SAVED";
 
 982         $form->save_history($form->dbconnect(\%myconfig));
 
 984   # /saving the history
 
 986   $lxdebug->leave_sub();
 
 990   $lxdebug->enter_sub();
 
 992   $form->{script} = "oe.pl";
 
 994     ($form->{db} eq 'customer') ? "sales_order" : "purchase_order";
 
 996   if(!exists $form->{addition}) {
 
 997     $form->{snumbers} = qq|ordnumber_| . $form->{ordnumber};
 
 998         $form->{addition} = "SAVED";
 
 999         $form->save_history($form->dbconnect(\%myconfig));
 
1001   # /saving the history
 
1003   $lxdebug->leave_sub();
 
1006 sub save_and_close {
 
1007   $lxdebug->enter_sub();
 
1009   # $locale->text('Customer saved!')
 
1010   # $locale->text('Vendor saved!')
 
1012   $msg = ucfirst $form->{db};
 
1015   $form->isblank("name", $locale->text("Name missing!"));
 
1016   if ($form->{"db"} eq "customer") {
 
1017     $rc = CT->save_customer(\%myconfig, \%$form);
 
1019     $rc = CT->save_vendor(\%myconfig, \%$form);
 
1022     $form->error($locale->text('customernumber not unique!'));
 
1024   # saving the history
 
1025   if(!exists $form->{addition}) {
 
1026     $form->{snumbers} = ($form->{"db"} eq "customer" ? qq|customernumber_| . $form->{customernumber} : qq|vendornumber_| . $form->{vendornumber});
 
1027     $form->{addition} = "SAVED";
 
1028         $form->save_history($form->dbconnect(\%myconfig));
 
1030   # /saving the history
 
1031   $form->redirect($locale->text($msg));
 
1033   $lxdebug->leave_sub();
 
1037   $lxdebug->enter_sub();
 
1039   # $locale->text('Customer saved!')
 
1040   # $locale->text('Vendor saved!')
 
1042   $msg = ucfirst $form->{db};
 
1045   $form->isblank("name", $locale->text("Name missing!"));
 
1048   if ($form->{"db"} eq "customer") {
 
1049     $res = CT->save_customer(\%myconfig, \%$form);
 
1051     $res = CT->save_vendor(\%myconfig, \%$form);
 
1055     if ($form->{"db"} eq "customer") {
 
1056       $form->error($locale->text('This customer number is already in use.'));
 
1058       $form->error($locale->text('This vendor number is already in use.'));
 
1061   # saving the history
 
1062   if(!exists $form->{addition}) {
 
1063     $form->{snumbers} = ($form->{"db"} eq "customer" ? qq|customernumber_| . $form->{customernumber} : qq|vendornumber_| . $form->{vendornumber});
 
1064         $form->{addition} = "SAVED";
 
1065         $form->save_history($form->dbconnect(\%myconfig));
 
1067   # /saving the history
 
1070   $lxdebug->leave_sub();
 
1074   $lxdebug->enter_sub();
 
1076   # $locale->text('Customer deleted!')
 
1077   # $locale->text('Cannot delete customer!')
 
1078   # $locale->text('Vendor deleted!')
 
1079   # $locale->text('Cannot delete vendor!')
 
1081   CT->delete(\%myconfig, \%$form);
 
1083   $msg = ucfirst $form->{db};
 
1084   $msg .= " deleted!";
 
1085   # saving the history
 
1086   if(!exists $form->{addition}) {
 
1087     $form->{snumbers} = ($form->{"db"} eq "customer" ? qq|customernumber_| . $form->{customernumber} : qq|vendornumber_| . $form->{vendornumber});
 
1088         $form->{addition} = "DELETED";
 
1089         $form->save_history($form->dbconnect(\%myconfig));
 
1091   # /saving the history 
 
1092   $form->redirect($locale->text($msg));
 
1094   $msg = "Cannot delete $form->{db}";
 
1095   $form->error($locale->text($msg));
 
1097   $lxdebug->leave_sub();
 
1101   $lxdebug->enter_sub();
 
1106   $lxdebug->leave_sub();
 
1110   $lxdebug->enter_sub();
 
1113   $lxdebug->leave_sub();
 
1117   $lxdebug->enter_sub();
 
1119   CT->get_contact(\%myconfig, \%$form);
 
1122   $result = "$form->{cp_name}";
 
1123   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);
 
1126   $lxdebug->leave_sub();
 
1131   $lxdebug->enter_sub();
 
1133   CT->get_shipto(\%myconfig, \%$form);
 
1136   $result = "$form->{shiptoname}";
 
1137   map { $result .= "__pjx__" . $form->{$_} } qw(shiptodepartment_1 shiptodepartment_2 shiptostreet shiptozipcode shiptocity shiptocountry shiptocontact shiptophone shiptofax shiptoemail);
 
1140   $lxdebug->leave_sub();
 
1145   $lxdebug->enter_sub();
 
1147   CT->get_delivery(\%myconfig, \%$form );
 
1150     $form->sort_columns(shiptoname,
 
1161   $column_header{shiptoname} =
 
1162     qq|<th class=listheading>| . $locale->text('Shipping Address') . qq|</th>|;
 
1163   $column_header{invnumber} =
 
1164       qq|<th class=listheading>|. $locale->text('Invoice'). qq|</th>|;
 
1165   $column_header{ordnumber} =
 
1166       qq|<th class=listheading>|. $locale->text('Order'). qq|</th>|;
 
1167   $column_header{transdate} =
 
1168     qq|<th class=listheading>| . $locale->text('Invdate') . qq|</th>|;
 
1169   $column_header{description} =
 
1170     qq|<th class=listheading>| . $locale->text('Description') . qq|</th>|;
 
1171   $column_header{qty} =
 
1172     qq|<th class=listheading>| . $locale->text('Qty') . qq|</th>|;
 
1173   $column_header{unit} =
 
1174     qq|<th class=listheading>| . $locale->text('Unit') . qq|</th>|;
 
1175   $column_header{sellprice} =
 
1176     qq|<th class=listheading>| . $locale->text('Sell Price') . qq|</th>|;
 
1183         <tr class=listheading>
 
1186   map { $result .= "$column_header{$_}\n" } @column_index;
 
1193   foreach $ref (@{ $form->{DELIVERY} }) {
 
1195     if ($ref->{shiptoname} eq $sameshiptoname) {
 
1196       map { $column_data{$_} = "<td>$ref->{$_} </td>" } @column_index;
 
1197       $column_data{shiptoname} = "<td> </td>";
 
1199       map { $column_data{$_} = "<td>$ref->{$_} </td>" } @column_index;
 
1201     $column_data{sellprice} = "<td>". $form->format_amount(\%myconfig,$ref->{sellprice},2)." </td>";
 
1205         <tr class=listrow$i>
 
1208     map { $result .= "$column_data{$_}\n" } @column_index;
 
1214     $sameshiptoname = $ref->{shiptoname};
 
1226   $lxdebug->leave_sub();
 
1230 sub continue { call_sub($form->{nextsub}); }