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 my $vc_business_type = $form->{db} eq "customer" ?
75 $locale->text("Customer type") : $locale->text("Vendor type");
77 $form->get_lists("business_types" => "ALL_BUSINESS_TYPES");
78 my (%labels, @values);
81 if (scalar(@{ $form->{ALL_BUSINESS_TYPES} }) != 0) {
83 foreach my $item (@{ $form->{ALL_BUSINESS_TYPES} }) {
84 push(@values, $item->{id});
85 $labels{$item->{id}} = $item->{description};
90 <th align="right" nowrap>${vc_business_type}</th>
92 . NTI($cgi->popup_menu('-name' => 'business_id', '-values' => \@values,
93 '-labels' => \%labels))
99 $label = ucfirst $form->{db};
100 $form->{title} = $locale->text($label . "s");
101 $form->{fokus} = 'Form.name';
106 <body onload="fokus()">
108 <form method=post action=$form->{script} name="Form">
110 <input type=hidden name=db value=$form->{db}>
114 <th class=listtop>$form->{title}</th>
121 <th align=right nowrap>| . $locale->text($label . ' Number') . qq|</th>
122 <td><input name=$form->{db}number size=35></td>
125 <th align=right nowrap>| . $locale->text('Company Name') . qq|</th>
126 <td><input name=name size=35></td>
129 <th align=right nowrap>| . $locale->text('Contact') . qq|</th>
130 <td><input name=contact size=35></td>
133 <th align=right nowrap>| . $locale->text('E-mail') . qq|</th>
134 <td><input name=email size=35></td>
139 <td><input name=status class=radio type=radio value=all checked> |
140 . $locale->text('All') . qq|
141 <input name=status class=radio type=radio value=orphaned> |
142 . $locale->text('Orphaned') . qq|</td>
146 <td><input name="obsolete" class="radio" type="radio" value="all"> |
147 . $locale->text('All') . qq|
148 <input name="obsolete" class="radio" type="radio" value="Y"> |
149 . $locale->text('Obsolete') . qq|
150 <input name="obsolete" class="radio" type="radio" value="N" checked> |
151 . $locale->text('Not obsolete') . qq|</td>
154 <th align=right nowrap>| . $locale->text('Include in Report') . qq|</th>
158 <td><input name="l_id" type=checkbox class=checkbox value=Y> |
159 . $locale->text('ID') . qq|</td>
160 <td><input name="l_$form->{db}number" type=checkbox class=checkbox value=Y> |
161 . $locale->text($label . ' Number') . qq|</td>
162 <td><input name="l_name" type=checkbox class=checkbox value=Y checked> |
163 . $locale->text('Company Name') . qq|</td>
164 <td><input name="l_address" type=checkbox class=checkbox value=Y> |
165 . $locale->text('Address') . qq|</td>
168 <td><input name="l_contact" type=checkbox class=checkbox value=Y checked> |
169 . $locale->text('Contact') . qq|</td>
170 <td><input name="l_phone" type=checkbox class=checkbox value=Y checked> |
171 . $locale->text('Phone') . qq|</td>
172 <td><input name="l_fax" type=checkbox class=checkbox value=Y> |
173 . $locale->text('Fax') . qq|</td>
174 <td><input name="l_email" type=checkbox class=checkbox value=Y checked> |
175 . $locale->text('E-mail') . qq|</td>
178 <td><input name="l_taxnumber" type=checkbox class=checkbox value=Y> |
179 . $locale->text('Tax Number') . qq|</td>
180 <td><input name="l_sic_code" type=checkbox class=checkbox value=Y> |
181 . $locale->text('SIC') . qq|</td>
182 <td><input name="l_business" type=checkbox class=checkbox value=Y> |
183 . $vc_business_type . qq|</td>
186 <td><input name="l_invnumber" type=checkbox class=checkbox value=Y> |
187 . $locale->text('Invoices') . qq|</td>
188 <td><input name="l_ordnumber" type=checkbox class=checkbox value=Y> |
189 . $locale->text('Orders') . qq|</td>
190 <td><input name="l_quonumber" type=checkbox class=checkbox value=Y> |
191 . $locale->text('Quotations') . qq|</td>
200 <td><hr size=3 noshade></td>
204 <input type=hidden name=nextsub value=list_names>
206 <input type=hidden name=login value=$form->{login}>
207 <input type=hidden name=password value=$form->{password}>
210 <input type=submit class=submit name=action value="|
211 . $locale->text('Continue') . qq|">
217 $lxdebug->leave_sub();
221 $lxdebug->enter_sub();
223 $form->{IS_CUSTOMER} = $form->{db} eq 'customer';
225 CT->search(\%myconfig, \%$form);
228 if ($form->{status} eq 'all') {
229 push @options, $locale->text('All');
231 } elsif ($form->{status} eq 'orphaned') {
232 push @options, $locale->text('Orphaned');
236 push @options, $locale->text('Name') . " : $form->{name}";
238 if ($form->{contact}) {
239 push @options, $locale->text('Contact') . " : $form->{contact}";
241 if ($form->{"$form->{db}number"}) {
242 push @options, $locale->text('Number') . qq| : $form->{"$form->{db}number"}|;
244 if ($form->{email}) {
245 push @options, $locale->text('E-mail') . " : $form->{email}";
249 'id', 'name', "$form->{db}number", 'address', 'contact', 'phone',
250 'fax', 'email', 'taxnumber', 'sic_code', 'business', 'invnumber',
251 'ordnumber', 'quonumber'
255 'id' => { 'text' => $locale->text('ID'), },
256 "$form->{db}number" => { 'text' => $form->{IS_CUSTOMER} ? $locale->text('Customer Number') : $locale->text('Vendor Number'), },
257 'name' => { 'text' => $locale->text('Name'), },
258 'address' => { 'text' => $locale->text('Address'), },
259 'contact' => { 'text' => $locale->text('Contact'), },
260 'phone' => { 'text' => $locale->text('Phone'), },
261 'fax' => { 'text' => $locale->text('Fax'), },
262 'email' => { 'text' => $locale->text('E-mail'), },
263 'cc' => { 'text' => $locale->text('Cc'), },
264 'taxnumber' => { 'text' => $locale->text('Tax Number'), },
265 'sic_code' => { 'text' => $locale->text('SIC'), },
266 'business' => { 'text' => $locale->text('Type of Business'), },
267 'invnumber' => { 'text' => $locale->text('Invoice'), },
268 'ordnumber' => { 'text' => $form->{IS_CUSTOMER} ? $locale->text('Sales Order') : $locale->text('Purchase Order'), },
269 'quonumber' => { 'text' => $form->{IS_CUSTOMER} ? $locale->text('Quotation') : $locale->text('Request for Quotation'), },
272 map { $column_defs{$_}->{visible} = $form->{"l_$_"} eq 'Y' } @columns;
274 my @hidden_variables = (qw(db status obsolete), map { "l_$_" } @columns);
275 my @hidden_nondefault = grep({ $form->{$_} } @hidden_variables);
276 my $callback = build_std_url('action=list_names', grep { $form->{$_} } @hidden_variables);
277 $form->{callback} = "$callback&sort=" . E($form->{sort});
279 map { $column_defs{$_}->{link} = "${callback}&sort=${_}" } @columns;
281 my ($ordertype, $quotationtype, $attachment_basename);
282 if ($form->{IS_CUSTOMER}) {
283 $form->{title} = $locale->text('Customers');
284 $ordertype = 'sales_order';
285 $quotationtype = 'sales_quotation';
286 $attachment_basename = $locale->text('customer_list');
289 $form->{title} = $locale->text('Vendors');
290 $ordertype = 'purchase_order';
291 $quotationtype = 'request_quotation';
292 $attachment_basename = $locale->text('vendor_list');
295 my $report = SL::ReportGenerator->new(\%myconfig, $form);
297 $report->set_options('top_info_text' => join("\n", @options),
298 'raw_bottom_info_text' => $form->parse_html_template2('ct/list_names_bottom'),
299 'output_format' => 'HTML',
300 'title' => $form->{title},
301 'attachment_basename' => $attachment_basename . strftime('_%Y%m%d', localtime time),
303 $report->set_options_from_form();
305 $report->set_columns(%column_defs);
306 $report->set_column_order(@columns);
308 $report->set_export_options('list_names', @hidden_variables);
310 $report->set_sort_indicator($form->{sort}, 1);
314 foreach my $ref (@{ $form->{CT} }) {
315 my $row = { map { $_ => { 'data' => '' } } @columns };
317 if ($ref->{id} ne $previous_id) {
318 $previous_id = $ref->{id};
319 map { $row->{$_}->{data} = $ref->{$_} } @columns;
321 $row->{name}->{link} = build_std_url('action=edit', 'id=' . E($ref->{id}), 'callback', @hidden_nondefault);
322 $row->{email}->{link} = 'mailto:' . E($ref->{email});
325 my $base_url = build_std_url("script=$ref->{module}.pl", 'action=edit', 'id=' . E($ref->{invid}), 'callback', @hidden_nondefault);
326 $row->{invnumber}->{link} = $base_url;
327 $row->{ordnumber}->{link} = $base_url . "&type=${ordertype}";
328 $row->{quonumber}->{link} = $base_url . "&type=${quotationtype}";
329 my $column = $ref->{formtype} eq 'invoice' ? 'invnumber' : $ref->{formtype} eq 'order' ? 'ordnumber' : 'quonumber';
330 $row->{$column}->{data} = $ref->{$column};
332 $report->add_data($row);
335 $report->generate_with_headers();
337 $lxdebug->leave_sub();
341 $lxdebug->enter_sub();
343 # show history button
344 $form->{javascript} = qq|<script type=text/javascript src=js/show_history.js></script>|;
345 #/show hhistory button
347 # $locale->text('Edit Customer')
348 # $locale->text('Edit Vendor')
350 CT->get_tuple(\%myconfig, \%$form);
351 CT->populate_drop_down_boxes(\%myconfig, \%$form);
353 # format " into "
354 map { $form->{$_} =~ s/\"/"/g } keys %$form;
356 $form->{title} = "Edit";
359 $form->{discount} *= 100;
364 $lxdebug->leave_sub();
368 $lxdebug->enter_sub();
370 $form->get_lists("employees" => "ALL_SALESMEN",
371 "taxzones" => "ALL_TAXZONES");
373 $form->{taxincluded} = ($form->{taxincluded}) ? "checked" : "";
374 $form->{creditlimit} =
375 $form->format_amount(\%myconfig, $form->{creditlimit}, 0);
376 $form->{discount} = $form->format_amount(\%myconfig, $form->{discount});
378 if ($myconfig{role} eq 'admin') {
381 <th align=right nowrap>| . $locale->text('Bcc') . qq|</th>
382 <td><input name=bcc size=35 value="$form->{bcc}"></td>
386 $form->{obsolete} = "checked" if $form->{obsolete};
388 $lang = qq|<option value=""></option>|;
389 foreach $item (@{ $form->{languages} }) {
390 if ($form->{language_id} eq $item->{id}) {
391 $lang .= qq|<option value="$item->{id}" selected>$item->{description}</option>|;
393 $lang .= qq|<option value="$item->{id}">$item->{description}</option>|;
397 $payment = qq|<option value=""></option>|;
398 foreach $item (@{ $form->{payment_terms} }) {
399 if ($form->{payment_id} eq $item->{id}) {
400 $payment .= qq|<option value="$item->{id}" selected>$item->{description}</option>|;
402 $payment .= qq|<option value="$item->{id}">$item->{description}</option>|;
407 if ($form->{db} eq "customer") {
408 $form->{taxzone_id} = 0;
410 $form->{taxzone_id} = 0;
416 foreach my $item (@{ $form->{"ALL_TAXZONES"} }) {
417 push(@values, $item->{"id"});
418 $labels{$item->{"id"}} = $item->{"description"};
422 <th align=right>| . $locale->text('Steuersatz') . qq|</th>
424 NTI($cgi->popup_menu('-name' => 'taxzone_id', '-default' => $form->{"taxzone_id"},
425 '-values' => \@values, '-labels' => \%labels)) . qq|
430 "$form->{script}?login=$form->{login}&password=$form->{password}&action=get_contact";
432 my $pjx = new CGI::Ajax( 'get_contact' => $get_contact_url );
433 $form->{selectcontact} = "<option value=0>" . $locale->text('New contact') . "</option>";
434 if (@{ $form->{CONTACTS} }) {
435 foreach $item (@{ $form->{CONTACTS} }) {
436 if ($item->{cp_id} == $form->{cp_id}) {
437 $form->{selectcontact} .=
438 qq|<option value=$item->{cp_id} selected>$item->{cp_name}</option>\n|;
440 $form->{selectcontact} .=
441 qq|<option value=$item->{cp_id}>$item->{cp_name}</option>\n|;
446 push(@ { $form->{AJAX} }, $pjx);
447 $ansprechpartner = qq|
449 <th align=right>| . $locale->text('Ansprechpartner') . qq|</th>
450 <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>
451 <input type=hidden name=selectcontact value="$form->{selectcontact}">
454 "$form->{script}?login=$form->{login}&password=$form->{password}&action=get_shipto";
456 my $pjy = new CGI::Ajax( 'get_shipto' => $get_shipto_url );
457 $form->{selectshipto} = "<option value=0></option>";
458 $form->{selectshipto} .= "<option value=0>Alle</option>";
459 if (@{ $form->{SHIPTO} }) {
460 foreach $item (@{ $form->{SHIPTO} }) {
461 if ($item->{shipto_id} == $form->{shipto_id}) {
462 $form->{selectshipto} .=
463 "<option value=$item->{shipto_id} selected>$item->{shiptoname} $item->{shiptodepartment_1}\n";
465 $form->{selectshipto} .=
466 "<option value=$item->{shipto_id}>$item->{shiptoname} $item->{shiptodepartment_1}\n";
471 push(@ { $form->{AJAX} }, $pjy);
475 <th align=right>| . $locale->text('Shipping Address') . qq|</th>
476 <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>
477 <input type=hidden name=selectshipto value="$form->{selectshipto}">
482 "$form->{script}?login=$form->{login}&password=$form->{password}&action=get_delivery";
484 my $pjz = new CGI::Ajax( 'get_delivery' => $get_delivery_url );
486 push(@ { $form->{AJAX} }, $pjz);
490 <th align=right>| . $locale->text('Shipping Address') . qq|</th>
491 <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>
494 $form->{selectbusiness} = qq|<option>\n|;
496 $form->{selectbusiness} .=
497 qq|<option value=$_->{id}>$_->{description}\n|
498 } @{ $form->{all_business} };
499 if ($form->{business_save}) {
500 $form->{selectbusiness} = $form->{business_save};
502 $form->{selectbusiness} =~
503 s/<option value=$form->{business}>/<option value=$form->{business} selected>/;
505 $label = ucfirst $form->{db};
506 if ($form->{title} eq "Edit") {
507 $form->{title} = $locale->text("$form->{title} $label") . " $form->{name}";
509 $form->{title} = $locale->text("$form->{title} $label");
511 if ($form->{title_save}) {
512 $form->{title} = $form->{title_save};
514 if ($form->{db} eq 'vendor') {
516 <th align=right>| . $locale->text('Kundennummer') . qq|</th>
517 <td><input name=v_customer_id size=10 maxlength=35 value="$form->{v_customer_id}"></td>
521 if ($form->{db} eq 'customer') {
524 <th align=right>| . $locale->text('KNr. beim Kunden') . qq|</th>
525 <td><input name=c_vendor_id size=10 maxlength=35 value="$form->{c_vendor_id}"></td>
530 <th align=right>| . $locale->text('Type of Business') . qq|</th>
531 <td><select name=business>$form->{selectbusiness}</select></td>
536 if ($form->{db} eq "customer") {
537 my (@salesman_values, %salesman_labels);
538 push(@salesman_values, undef);
539 foreach my $item (@{ $form->{ALL_SALESMEN} }) {
540 push(@salesman_values, $item->{id});
541 $salesman_labels{$item->{id}} = $item->{name} ne "" ? $item->{name} : $item->{login};
545 qq| <th align="right">| . $locale->text('Salesman') . qq|</th>
547 NTI($cgi->popup_menu('-name' => 'salesman_id', '-default' => $form->{salesman_id},
548 '-values' => \@salesman_values, '-labels' => \%salesman_labels))
552 ## LINET: Create a drop-down box with all prior titles and greetings.
553 CT->query_titles_and_greetings(\%myconfig, \%$form);
555 $select_title = qq| <select name=selected_cp_title><option></option>|;
556 map({ $select_title .= qq|<option>$_</option>|; } @{ $form->{TITLES} });
557 $select_title .= qq|</select>|;
560 qq| <select name=selected_cp_greeting><option></option>|;
562 { $select_greeting .= qq|<option>$_</option>|; } @{ $form->{GREETINGS} });
563 $select_greeting .= qq|</select>|;
565 $select_company_greeting =
566 qq| <select name=selected_company_greeting><option></option>|;
568 { $select_company_greeting .= qq|<option>$_</option>|; } @{ $form->{COMPANY_GREETINGS} });
569 $select_company_greeting .= qq|</select>|;
572 qq| <select name=selected_cp_abteilung><option></option>|;
574 { $select_department .= qq|<option>$_</option>|; } @{ $form->{DEPARTMENT} });
575 $select_department .= qq|</select>|;
578 if ($form->{db} eq 'customer') {
580 #get pricegroup and form it
581 $form->get_pricegroup(\%myconfig, { all => 1 });
583 $form->{pricegroup} = "$form->{klass}";
584 $form->{pricegroup_id} = "$form->{klass}";
586 if (@{ $form->{all_pricegroup} }) {
588 $form->{selectpricegroup} = qq|<option>\n|;
590 $form->{selectpricegroup} .=
591 qq|<option value="$_->{id}">$_->{pricegroup}\n|
592 } @{ $form->{all_pricegroup} };
595 if ($form->{selectpricegroup}) {
596 $form->{selectpricegroup} = $form->unescape($form->{selectpricegroup});
599 qq|<input type=hidden name=selectpricegroup value="|
600 . $form->escape($form->{selectpricegroup}, 1) . qq|">|;
602 $form->{selectpricegroup} =~
603 s/(<option value="\Q$form->{klass}\E")/$1 selected/;
606 qq|<select name=klass>$form->{selectpricegroup}</select>|;
611 # $locale->text('Customer Number')
612 # $locale->text('Vendor Number')
613 $form->{fokus} = "ct.greeting";
614 $form->{jsscript} = 1;
618 <body onLoad="fokus()">
621 <th class=listtop>$form->{title}</th>
626 <form method=post name="ct" action=$form->{script} onKeyUp="highlight(event)" onClick="highlight(event)">
630 <ul id="maintab" class="shadetabs">
631 <li class="selected"><a href="#" rel="billing">|
632 . $locale->text('Billing Address') . qq|</a></li>
633 <li><a href="#" rel="shipto">|
634 . $locale->text('Shipping Address') . qq|</a></li>
635 <li><a href="#" rel="contacts">Ansprechpartner</a></li>
636 <li><a href="#" rel="deliveries">|
637 . $locale->text('Lieferungen') . qq|</a></li>
641 <div class="tabcontentstyle">
643 <div id="billing" class="tabcontent">
648 <th align=right nowrap>| . $locale->text($label . ' Number') . qq|</th>
649 <td><input name="$form->{db}number" size=35 maxlength=35 value="$form->{"$form->{db}number"}"></td>
652 <th align=right nowrap>| . $locale->text('Greeting') . qq|</th>
653 <td><input id=greeting name=greeting size=30 maxlength=30 value="$form->{greeting}">
654 $select_company_greeting</td>
657 <th align=right nowrap>| . $locale->text('Company Name') . qq|</th>
658 <td><input name=name size=35 maxlength=75 value="$form->{name}"></td>
661 <th align=right nowrap>| . $locale->text('Abteilung') . qq|</th>
662 <td><input name=department_1 size=16 maxlength=75 value="$form->{department_1}">
663 <input name=department_2 size=16 maxlength=75 value="$form->{department_2}"></td>
666 <th align=right nowrap>| . $locale->text('Street') . qq|</th>
667 <td><input name=street size=35 maxlength=75 value="$form->{street}"></td>
670 <th align=right nowrap>|
671 . $locale->text('Zipcode') . "/" . $locale->text('City') . qq|</th>
672 <td><input name=zipcode size=5 maxlength=10 value="$form->{zipcode}">
673 <input name=city size=30 maxlength=75 value="$form->{city}"></td>
676 <th align=right nowrap>| . $locale->text('Country') . qq|</th>
677 <td><input name=country size=35 maxlength=75 value="$form->{country}"></td>
680 <th align=right nowrap>| . $locale->text('Contact') . qq|</th>
681 <td><input name=contact size=28 maxlength=75 value="$form->{contact}"></td>
684 <th align=right nowrap>| . $locale->text('Phone') . qq|</th>
685 <td><input name=phone size=30 maxlength=30 value="$form->{phone}"></td>
688 <th align=right nowrap>| . $locale->text('Fax') . qq|</th>
689 <td><input name=fax size=30 maxlength=30 value="$form->{fax}"></td>
692 <th align=right nowrap>| . $locale->text('E-mail') . qq|</th>
693 <td><input name=email size=45 value="$form->{email}"></td>
696 <th align=right nowrap>| . $locale->text('Homepage') . qq|</th>
697 <td><input name=homepage size=45 value="$form->{homepage}"></td>
702 <th align=right>| . $locale->text('Credit Limit') . qq|</th>
703 <td><input name=creditlimit size=9 value="$form->{creditlimit}"></td>
704 <input type="hidden" name="terms" value="$form->{terms}">
705 <th align=right>| . $locale->text('Payment Terms') . qq|</th>
706 <td><select name=payment_id>$payment</select></td>
707 <th align=right>| . $locale->text('Discount') . qq|</th>
708 <td><input name=discount size=4 value="$form->{discount}">
712 <th align=right>| . $locale->text('Tax Number / SSN') . qq|</th>
713 <td><input name=taxnumber size=20 value="$form->{taxnumber}"></td>
714 <th align=right>| . $locale->text('USt-IdNr.') . qq|</th>
715 <td><input name="ustid" maxlength="14" size="20" value="$form->{ustid}"></td>
719 <th align=right>| . $locale->text('Account Number') . qq|</th>
720 <td><input name=account_number size=10 value="$form->{account_number}"></td>
721 <th align=right>| . $locale->text('Bank Code Number') . qq|</th>
722 <td><input name=bank_code size=10 value="$form->{bank_code}"></td>
723 <th align=right>| . $locale->text('Bank') . qq|</th>
724 <td><input name=bank size=30 value="$form->{bank}"></td>
728 <th align=right>| . $locale->text('Language') . qq|</th>
729 <td><select name=language_id>$lang
732 if ($form->{db} eq 'customer') {
735 <th align=right>| . $locale->text('Preisklasse') . qq|</th>
736 <td>$pricegroup</td>|;
740 <td align=right>| . $locale->text('Obsolete') . qq|</td>
741 <td><input name=obsolete class=checkbox type=checkbox value=1 $form->{obsolete}></td>
750 <th align=left nowrap>| . $locale->text('Notes') . qq|</th>
753 <td><textarea name=notes rows=3 cols=60 wrap=soft>$form->{notes}</textarea></td>
760 <br style="clear: left" /></div>|;
763 <div id="shipto" class="tabcontent">
768 <th align=right nowrap>| . $locale->text('Company Name') . qq|</th>
769 <td><input id=shiptoname name=shiptoname size=35 maxlength=75 value="$form->{shiptoname}"></td>
772 <th align=right nowrap>| . $locale->text('Abteilung') . qq|</th>
773 <td><input id=shiptodepartment_1 name=shiptodepartment_1 size=16 maxlength=75 value="$form->{shiptodepartment_1}">
774 <input id=shiptodepartment_2 name=shiptodepartment_2 size=16 maxlength=75 value="$form->{shiptodepartment_2}"></td>
777 <th align=right nowrap>| . $locale->text('Street') . qq|</th>
778 <td><input id=shiptostreet name=shiptostreet size=35 maxlength=75 value="$form->{shiptostreet}"></td>
781 <th align=right nowrap>|
782 . $locale->text('Zipcode') . "/" . $locale->text('City') . qq|</th>
783 <td><input id=shiptozipcode name=shiptozipcode size=5 maxlength=10 value="$form->{shiptozipcode}">
784 <input id=shiptocity name=shiptocity size=30 maxlength=75 value="$form->{shiptocity}"></td>
787 <th align=right nowrap>| . $locale->text('Country') . qq|</th>
788 <td><input id=shiptocountry name=shiptocountry size=35 maxlength=35 value="$form->{shiptocountry}"></td>
791 <th align=right nowrap>| . $locale->text('Contact') . qq|</th>
792 <td><input id=shiptocontact name=shiptocontact size=30 maxlength=75 value="$form->{shiptocontact}"></td>
795 <th align=right nowrap>| . $locale->text('Phone') . qq|</th>
796 <td><input id=shiptophone name=shiptophone size=30 maxlength=30 value="$form->{shiptophone}"></td>
799 <th align=right nowrap>| . $locale->text('Fax') . qq|</th>
800 <td><input id=shiptofax name=shiptofax size=30 maxlength=30 value="$form->{shiptofax}"></td>
803 <th align=right nowrap>| . $locale->text('E-mail') . qq|</th>
804 <td><input id=shiptoemail name=shiptoemail size=45 value="$form->{shiptoemail}"></td>
814 <br style="clear: left" /></div>|;
817 ##LINET - added fields for contact person
819 <div id="contacts" class="tabcontent">
823 <input type=hidden name=cp_id value=$form->{cp_id}>
827 <th align=left nowrap>| . $locale->text('Greeting') . qq|</th>
828 <td><input id=cp_greeting name=cp_greeting size=40 maxlength=40 value="$form->{cp_greeting}">
829 $select_greeting</td>
832 <th align=left nowrap>| . $locale->text('Title') . qq|</th>
833 <td><input id=cp_title name=cp_title size=40 maxlength=40 value="$form->{cp_title}">
837 <th align=left nowrap>| . $locale->text('Department') . qq|</th>
838 <td><input id=cp_abteilung name=cp_abteilung size=40 maxlength=40 value="$form->{cp_abteilung}">
839 $select_department</td>
842 <th align=left nowrap>|
843 . $locale->text('Given Name') . qq|</th>
844 <td><input id=cp_givenname name=cp_givenname size=40 maxlength=40 value="$form->{cp_givenname}"></td>
847 <th align=left nowrap>| . $locale->text('Name') . qq|</th>
848 <td><input id=cp_name name=cp_name size=40 maxlength=40 value="$form->{cp_name}"></td>
851 <th align=left nowrap>| . $locale->text('Phone1') . qq|</th>
852 <td><input id=cp_phone1 name=cp_phone1 size=40 maxlength=40 value="$form->{cp_phone1}"></td>
855 <th align=left nowrap>| . $locale->text('Phone2') . qq|</th>
856 <td><input id=cp_phone2 name=cp_phone2 size=40 maxlength=40 value="$form->{cp_phone2}"></td>
859 <th align=left nowrap>| . $locale->text('Fax') . qq|</th>
860 <td><input id=cp_fax name=cp_fax size=40 maxlength=40 value="$form->{cp_fax}"></td>
863 <th align=left nowrap>| . $locale->text('Mobile1') . qq|</th>
864 <td><input id=cp_mobile1 name=cp_mobile1 size=40 maxlength=40 value="$form->{cp_mobile1}"></td>
867 <th align=left nowrap>| . $locale->text('Mobile2') . qq|</th>
868 <td><input id=cp_mobile2 name=cp_mobile2 size=40 maxlength=40 value="$form->{cp_mobile2}"></td>
871 <th align=left nowrap>| . $locale->text('Sat. Phone') . qq|</th>
872 <td><input id=cp_satphone name=cp_satphone size=40 maxlength=40 value="$form->{cp_satphone}"></td>
875 <th align=left nowrap>| . $locale->text('Sat. Fax') . qq|</th>
876 <td><input id=cp_satfax name=cp_satfax size=40 maxlength=40 value="$form->{cp_satfax}"></td>
879 <th align=left nowrap>| . $locale->text('Project') . qq|</th>
880 <td><input id=cp_project name=cp_project size=40 maxlength=40 value="$form->{cp_project}"></td>
883 <th align=left nowrap>| . $locale->text('E-mail') . qq|</th>
884 <td><input id=cp_email name=cp_email size=40 maxlength=40 value="$form->{cp_email}"></td>
887 <th align=left nowrap>| . $locale->text('Private Phone') . qq|</th>
888 <td><input id=cp_privatphone name=cp_privatphone size=40 maxlength=40 value="$form->{cp_privatphone}"></td>
891 <th align=left nowrap>| . $locale->text('Private E-mail') . qq|</th>
892 <td><input id=cp_privatemail name=cp_privatemail size=40 maxlength=40 value="$form->{cp_privatemail}"></td>
895 <th align=left nowrap>| . $locale->text('Birthday') . qq|</th>
896 <td><input id=cp_birthday name=cp_birthday size=40 maxlength=40 value="$form->{cp_birthday}"></td>
902 <tr height="5"></tr>|;
912 <br style="clear: left" /></div>
913 <div id="deliveries" class="tabcontent">
917 <th align=left nowrap>| . $locale->text('From') . qq|</th>
918 <td><input id=from name=from size=10 maxlength=10 value="$form->{from}">
919 <input type="button" name="fromB" id="trigger_from" value="?"></td>
920 <th align=left nowrap>| . $locale->text('To (time)') . qq|</th>
921 <td><input id=to name=to size=10 maxlength=10 value="$form->{to}">
922 <input type="button" name="toB" id="trigger_to" value="?"></td>
931 <br style="clear: left" /></div>
935 | . $form->write_trigger(\%myconfig, 2, "fromB", "BL", "trigger_from",
936 "toB", "BL", "trigger_to");
938 $lxdebug->leave_sub();
942 $lxdebug->enter_sub();
944 $label = ucfirst $form->{db};
946 ($form->{db} eq 'customer')
947 ? $locale->text('Save and Quotation')
948 : $locale->text('Save and RFQ');
950 ($form->{db} eq 'customer')
951 ? $locale->text('Save and AR Transaction')
952 : $locale->text('Save and AP Transaction');
954 ##<input class=submit type=submit name=action value="|.$locale->text("Save and Quotation").qq|">
955 ##<input class=submit type=submit name=action value="|.$locale->text("Save and RFQ").qq|">
956 ##<input class=submit type=submit name=action value="|.$locale->text("Save and AR Transaction").qq|">
957 ##<input class=submit type=submit name=action value="|.$locale->text("Save and AP Transaction").qq|">
960 <input name=id type=hidden id=cvid value=$form->{id}>
961 <input name=business_save type=hidden value="$form->{selectbusiness}">
962 <input name=title_save type=hidden value="$form->{title}">
964 <input type=hidden name=login value=$form->{login}>
965 <input type=hidden name=password value=$form->{password}>
967 <input type=hidden name=callback value="$form->{callback}">
968 <input type=hidden name=db id=db value=$form->{db}>
973 <input class=submit type=submit name=action accesskey="s" value="|
974 . $locale->text("Save") . qq|">
975 <input class=submit type=submit name=action accesskey="s" value="|
976 . $locale->text("Save and Close") . qq|">
977 <input class=submit type=submit name=action value="$arap">
978 <input class=submit type=submit name=action value="|
979 . $locale->text("Save and Invoice") . qq|">
980 <input class=submit type=submit name=action value="|
981 . $locale->text("Save and Order") . qq|">
982 <input class=submit type=submit name=action value="$quotation">
985 if ($form->{id} && $form->{status} eq 'orphaned') {
986 print qq|<input class=submit type=submit name=action value="|
987 . $locale->text('Delete')
991 # button for saving history
992 if($form->{id} ne "") {
994 <input type=button class=submit onclick=set_history_window(|
996 . qq|); name=history id=history value=|
997 . $locale->text('history')
1000 # /button for saving history
1005 <script type="text/javascript">
1006 //Start Tab Content script for UL with id="maintab" Separate multiple ids each with a comma.
1007 initializetabcontent("maintab")
1013 $lxdebug->leave_sub();
1016 sub add_transaction {
1017 $lxdebug->enter_sub();
1019 # # saving the history
1020 # if(!exists $form->{addition}) {
1021 # $form->{addition} = "ADD TRANSACTION";
1022 # $form->save_history($form->dbconnect(\%myconfig));
1024 # # /saving the history
1026 $form->isblank("name", $locale->text("Name missing!"));
1027 if ($form->{"db"} eq "customer") {
1028 CT->save_customer(\%myconfig, \%$form);
1030 CT->save_vendor(\%myconfig, \%$form);
1033 $form->{callback} = $form->escape($form->{callback}, 1);
1034 $name = $form->escape("$form->{name}", 1);
1037 "$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}";
1040 $lxdebug->leave_sub();
1043 sub save_and_ap_transaction {
1044 $lxdebug->enter_sub();
1046 $form->{script} = "ap.pl";
1047 # saving the history
1048 if(!exists $form->{addition}) {
1049 $form->{snumbers} = qq|invnumber_| . $form->{invnumber};
1050 $form->{addition} = "SAVED";
1051 $form->save_history($form->dbconnect(\%myconfig));
1053 # /saving the history
1055 $lxdebug->leave_sub();
1058 sub save_and_ar_transaction {
1059 $lxdebug->enter_sub();
1061 $form->{script} = "ar.pl";
1062 # saving the history
1063 if(!exists $form->{addition}) {
1064 $form->{snumbers} = qq|invnumber_| . $form->{invnumber};
1065 $form->{addition} = "SAVED";
1066 $form->save_history($form->dbconnect(\%myconfig));
1068 # /saving the history
1070 $lxdebug->leave_sub();
1073 sub save_and_invoice {
1074 $lxdebug->enter_sub();
1076 $form->{script} = ($form->{db} eq 'customer') ? "is.pl" : "ir.pl";
1077 $form->{type} = "invoice";
1078 # saving the history
1079 if(!exists $form->{addition}) {
1080 $form->{snumbers} = qq|invnumber_| . $form->{invnumber};
1081 $form->{addition} = "SAVED";
1082 $form->save_history($form->dbconnect(\%myconfig));
1084 # /saving the history
1086 $lxdebug->leave_sub();
1090 $lxdebug->enter_sub();
1092 $form->{script} = "oe.pl";
1093 $form->{type} = "request_quotation";
1094 # saving the history
1095 if(!exists $form->{addition}) {
1096 $form->{snumbers} = qq|ordnumber_| . $form->{ordnumber};
1097 $form->{addition} = "SAVED";
1098 $form->save_history($form->dbconnect(\%myconfig));
1100 # /saving the history
1102 $lxdebug->leave_sub();
1105 sub save_and_quotation {
1106 $lxdebug->enter_sub();
1108 $form->{script} = "oe.pl";
1109 $form->{type} = "sales_quotation";
1110 # saving the history
1111 if(!exists $form->{addition}) {
1112 $form->{snumbers} = qq|ordnumber_| . $form->{ordnumber};
1113 $form->{addition} = "SAVED";
1114 $form->save_history($form->dbconnect(\%myconfig));
1116 # /saving the history
1118 $lxdebug->leave_sub();
1121 sub save_and_order {
1122 $lxdebug->enter_sub();
1124 $form->{script} = "oe.pl";
1126 ($form->{db} eq 'customer') ? "sales_order" : "purchase_order";
1127 # saving the history
1128 if(!exists $form->{addition}) {
1129 $form->{snumbers} = qq|ordnumber_| . $form->{ordnumber};
1130 $form->{addition} = "SAVED";
1131 $form->save_history($form->dbconnect(\%myconfig));
1133 # /saving the history
1135 $lxdebug->leave_sub();
1138 sub save_and_close {
1139 $lxdebug->enter_sub();
1141 # $locale->text('Customer saved!')
1142 # $locale->text('Vendor saved!')
1144 $msg = ucfirst $form->{db};
1147 $form->isblank("name", $locale->text("Name missing!"));
1148 if ($form->{"db"} eq "customer") {
1149 $rc = CT->save_customer(\%myconfig, \%$form);
1151 $rc = CT->save_vendor(\%myconfig, \%$form);
1154 $form->error($locale->text('customernumber not unique!'));
1156 # saving the history
1157 if(!exists $form->{addition}) {
1158 $form->{snumbers} = ($form->{"db"} eq "customer" ? qq|customernumber_| . $form->{customernumber} : qq|vendornumber_| . $form->{vendornumber});
1159 $form->{addition} = "SAVED";
1160 $form->save_history($form->dbconnect(\%myconfig));
1162 # /saving the history
1163 $form->redirect($locale->text($msg));
1165 $lxdebug->leave_sub();
1169 $lxdebug->enter_sub();
1171 # $locale->text('Customer saved!')
1172 # $locale->text('Vendor saved!')
1174 $msg = ucfirst $form->{db};
1177 $form->isblank("name", $locale->text("Name missing!"));
1180 if ($form->{"db"} eq "customer") {
1181 $res = CT->save_customer(\%myconfig, \%$form);
1183 $res = CT->save_vendor(\%myconfig, \%$form);
1187 if ($form->{"db"} eq "customer") {
1188 $form->error($locale->text('This customer number is already in use.'));
1190 $form->error($locale->text('This vendor number is already in use.'));
1193 # saving the history
1194 if(!exists $form->{addition}) {
1195 $form->{snumbers} = ($form->{"db"} eq "customer" ? qq|customernumber_| . $form->{customernumber} : qq|vendornumber_| . $form->{vendornumber});
1196 $form->{addition} = "SAVED";
1197 $form->save_history($form->dbconnect(\%myconfig));
1199 # /saving the history
1202 $lxdebug->leave_sub();
1206 $lxdebug->enter_sub();
1208 # $locale->text('Customer deleted!')
1209 # $locale->text('Cannot delete customer!')
1210 # $locale->text('Vendor deleted!')
1211 # $locale->text('Cannot delete vendor!')
1213 CT->delete(\%myconfig, \%$form);
1215 $msg = ucfirst $form->{db};
1216 $msg .= " deleted!";
1217 # saving the history
1218 if(!exists $form->{addition}) {
1219 $form->{snumbers} = ($form->{"db"} eq "customer" ? qq|customernumber_| . $form->{customernumber} : qq|vendornumber_| . $form->{vendornumber});
1220 $form->{addition} = "DELETED";
1221 $form->save_history($form->dbconnect(\%myconfig));
1223 # /saving the history
1224 $form->redirect($locale->text($msg));
1226 $msg = "Cannot delete $form->{db}";
1227 $form->error($locale->text($msg));
1229 $lxdebug->leave_sub();
1233 $lxdebug->enter_sub();
1238 $lxdebug->leave_sub();
1242 $lxdebug->enter_sub();
1245 $lxdebug->leave_sub();
1249 $lxdebug->enter_sub();
1251 CT->get_contact(\%myconfig, \%$form);
1254 $result = "$form->{cp_name}";
1255 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);
1258 $lxdebug->leave_sub();
1263 $lxdebug->enter_sub();
1265 CT->get_shipto(\%myconfig, \%$form);
1268 $result = "$form->{shiptoname}";
1269 map { $result .= "__pjx__" . $form->{$_} } qw(shiptodepartment_1 shiptodepartment_2 shiptostreet shiptozipcode shiptocity shiptocountry shiptocontact shiptophone shiptofax shiptoemail);
1272 $lxdebug->leave_sub();
1277 $lxdebug->enter_sub();
1279 CT->get_delivery(\%myconfig, \%$form );
1282 $form->sort_columns(shiptoname,
1292 $column_header{shiptoname} =
1293 qq|<th class=listheading>| . $locale->text('Shipping Address') . qq|</th>|;
1294 $column_header{invnumber} =
1295 qq|<th class=listheading>|. $locale->text('Invoice'). qq|</th>|;
1296 $column_header{ordnumber} =
1297 qq|<th class=listheading>|. $locale->text('Order'). qq|</th>|;
1298 $column_header{transdate} =
1299 qq|<th class=listheading>| . $locale->text('Invdate') . qq|</th>|;
1300 $column_header{description} =
1301 qq|<th class=listheading>| . $locale->text('Description') . qq|</th>|;
1302 $column_header{qty} =
1303 qq|<th class=listheading>| . $locale->text('Qty') . qq|</th>|;
1304 $column_header{unit} =
1305 qq|<th class=listheading>| . $locale->text('Unit') . qq|</th>|;
1312 <tr class=listheading>
1315 map { $result .= "$column_header{$_}\n" } @column_index;
1322 foreach $ref (@{ $form->{DELIVERY} }) {
1324 if ($ref->{shiptoname} eq $sameshiptoname) {
1325 map { $column_data{$_} = "<td>$ref->{$_} </td>" } @column_index;
1326 $column_data{shiptoname} = "<td> </td>";
1328 map { $column_data{$_} = "<td>$ref->{$_} </td>" } @column_index;
1334 <tr class=listrow$i>
1337 map { $result .= "$column_data{$_}\n" } @column_index;
1343 $sameshiptoname = $ref->{shiptoname};
1355 $lxdebug->leave_sub();
1359 sub continue { call_sub($form->{nextsub}); }