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')
45 require "bin/mozilla/common.pl";
52 $lxdebug->enter_sub();
54 $form->{title} = "Add";
57 "$form->{script}?action=add&db=$form->{db}&path=$form->{path}&login=$form->{login}&password=$form->{password}"
58 unless $form->{callback};
60 CT->taxaccounts(\%myconfig, \%$form);
65 $lxdebug->leave_sub();
69 $lxdebug->enter_sub();
71 $label = ucfirst $form->{db};
72 $form->{title} = $locale->text($label . "s");
74 if ($form->{db} eq 'vendor') {
76 <td><input name="l_gifi_accno" type=checkbox class=checkbox value=Y> |
77 . $locale->text('GIFI') . qq|</td>
86 <form method=post action=$form->{script}>
88 <input type=hidden name=db value=$form->{db}>
92 <th class=listtop>$form->{title}</th>
99 <th align=right nowrap>| . $locale->text($label . ' Number') . qq|</th>
100 <td><input name=$form->{db}number size=35></td>
103 <th align=right nowrap>| . $locale->text('Company Name') . qq|</th>
104 <td><input name=name size=35></td>
107 <th align=right nowrap>| . $locale->text('Contact') . qq|</th>
108 <td><input name=contact size=35></td>
111 <th align=right nowrap>| . $locale->text('E-mail') . qq|</th>
112 <td><input name=email size=35></td>
116 <td><input name=status class=radio type=radio value=all checked> |
117 . $locale->text('All') . qq|
118 <input name=status class=radio type=radio value=orphaned> |
119 . $locale->text('Orphaned') . qq|</td>
122 <th align=right nowrap>| . $locale->text('Include in Report') . qq|</th>
126 <td><input name="l_id" type=checkbox class=checkbox value=Y> |
127 . $locale->text('ID') . qq|</td>
128 <td><input name="l_$form->{db}number" type=checkbox class=checkbox value=Y> |
129 . $locale->text($label . ' Number') . qq|</td>
130 <td><input name="l_name" type=checkbox class=checkbox value=Y checked> |
131 . $locale->text('Company Name') . qq|</td>
132 <td><input name="l_address" type=checkbox class=checkbox value=Y> |
133 . $locale->text('Address') . qq|</td>
136 <td><input name="l_contact" type=checkbox class=checkbox value=Y checked> |
137 . $locale->text('Contact') . qq|</td>
138 <td><input name="l_phone" type=checkbox class=checkbox value=Y checked> |
139 . $locale->text('Phone') . qq|</td>
140 <td><input name="l_fax" type=checkbox class=checkbox value=Y> |
141 . $locale->text('Fax') . qq|</td>
142 <td><input name="l_email" type=checkbox class=checkbox value=Y checked> |
143 . $locale->text('E-mail') . qq|</td>
146 <td><input name="l_taxnumber" type=checkbox class=checkbox value=Y> |
147 . $locale->text('Tax Number') . qq|</td>
149 <td><input name="l_sic_code" type=checkbox class=checkbox value=Y> |
150 . $locale->text('SIC') . qq|</td>
151 <td><input name="l_business" type=checkbox class=checkbox value=Y> |
152 . $locale->text('Type of Business') . qq|</td>
155 <td><input name="l_invnumber" type=checkbox class=checkbox value=Y> |
156 . $locale->text('Invoices') . qq|</td>
157 <td><input name="l_ordnumber" type=checkbox class=checkbox value=Y> |
158 . $locale->text('Orders') . qq|</td>
159 <td><input name="l_quonumber" type=checkbox class=checkbox value=Y> |
160 . $locale->text('Quotations') . qq|</td>
169 <td><hr size=3 noshade></td>
173 <input type=hidden name=nextsub value=list_names>
175 <input type=hidden name=path value=$form->{path}>
176 <input type=hidden name=login value=$form->{login}>
177 <input type=hidden name=password value=$form->{password}>
180 <input type=submit class=submit name=action value="|
181 . $locale->text('Continue') . qq|">
187 $lxdebug->leave_sub();
190 sub search_delivery {
191 $lxdebug->enter_sub();
193 $label = ucfirst $form->{db};
194 $form->{title} = $locale->text($label . "s");
196 if ($form->{db} eq 'vendor') {
198 <td><input name="l_gifi_accno" type=checkbox class=checkbox value=Y> |
199 . $locale->text('GIFI') . qq|</td>
208 <form method=post action=$form->{script}>
210 <input type=hidden name=db value=$form->{db}>
214 <th class=listtop>$form->{title}</th>
221 <th align=right nowrap>| . $locale->text($label . ' Number') . qq|</th>
222 <td><input name=$form->{db}number size=35></td>
225 <th align=right nowrap>| . $locale->text('Company Name') . qq|</th>
226 <td><input name=name size=35></td>
229 <th align=right nowrap>| . $locale->text('Contact') . qq|</th>
230 <td><input name=contact size=35></td>
233 <th align=right nowrap>| . $locale->text('E-mail') . qq|</th>
234 <td><input name=email size=35></td>
238 <td><input name=status class=radio type=radio value=all checked> |
239 . $locale->text('All') . qq|
240 <input name=status class=radio type=radio value=orphaned> |
241 . $locale->text('Orphaned') . qq|</td>
244 <th align=right nowrap>| . $locale->text('Include in Report') . qq|</th>
248 <td><input name="l_id" type=checkbox class=checkbox value=Y> |
249 . $locale->text('ID') . qq|</td>
250 <td><input name="l_$form->{db}number" type=checkbox class=checkbox value=Y> |
251 . $locale->text($label . ' Number') . qq|</td>
252 <td><input name="l_name" type=checkbox class=checkbox value=Y checked> |
253 . $locale->text('Company Name') . qq|</td>
254 <td><input name="l_address" type=checkbox class=checkbox value=Y> |
255 . $locale->text('Address') . qq|</td>
258 <td><input name="l_contact" type=checkbox class=checkbox value=Y checked> |
259 . $locale->text('Contact') . qq|</td>
260 <td><input name="l_phone" type=checkbox class=checkbox value=Y checked> |
261 . $locale->text('Phone') . qq|</td>
262 <td><input name="l_fax" type=checkbox class=checkbox value=Y> |
263 . $locale->text('Fax') . qq|</td>
264 <td><input name="l_email" type=checkbox class=checkbox value=Y checked> |
265 . $locale->text('E-mail') . qq|</td>
268 <td><input name="l_taxnumber" type=checkbox class=checkbox value=Y> |
269 . $locale->text('Tax Number') . qq|</td>
271 <td><input name="l_sic_code" type=checkbox class=checkbox value=Y> |
272 . $locale->text('SIC') . qq|</td>
273 <td><input name="l_business" type=checkbox class=checkbox value=Y> |
274 . $locale->text('Type of Business') . qq|</td>
277 <td><input name="l_invnumber" type=checkbox class=checkbox value=Y> |
278 . $locale->text('Invoices') . qq|</td>
279 <td><input name="l_ordnumber" type=checkbox class=checkbox value=Y> |
280 . $locale->text('Orders') . qq|</td>
281 <td><input name="l_quonumber" type=checkbox class=checkbox value=Y> |
282 . $locale->text('Quotations') . qq|</td>
291 <td><hr size=3 noshade></td>
295 <input type=hidden name=nextsub value=list_names>
297 <input type=hidden name=path value=$form->{path}>
298 <input type=hidden name=login value=$form->{login}>
299 <input type=hidden name=password value=$form->{password}>
302 <input type=submit class=submit name=action value="|
303 . $locale->text('Continue') . qq|">
309 $lxdebug->leave_sub();
313 $lxdebug->enter_sub();
315 CT->search(\%myconfig, \%$form);
318 "$form->{script}?action=list_names&db=$form->{db}&path=$form->{path}&login=$form->{login}&password=$form->{password}&status=$form->{status}";
322 $form->sort_columns(id, name,
323 "$form->{db}number", address,
326 taxnumber, gifi_accno,
328 invnumber, ordnumber,
331 foreach $item (@columns) {
332 if ($form->{"l_$item"} eq "Y") {
333 push @column_index, $item;
335 # add column to href and callback
336 $callback .= "&l_$item=Y";
337 $href .= "&l_$item=Y";
341 ($form->{db} eq "customer")
342 ? $locale->text('Customer Number')
343 : $locale->text('Vendor Number');
345 if ($form->{status} eq 'all') {
346 $option = $locale->text('All');
348 if ($form->{status} eq 'orphaned') {
349 $option .= $locale->text('Orphaned');
352 $callback .= "&name=" . $form->escape($form->{name}, 1);
353 $href .= "&name=" . $form->escape($form->{name});
354 $option .= "\n<br>" . $locale->text('Name') . " : $form->{name}";
356 if ($form->{contact}) {
357 $callback .= "&contact=" . $form->escape($form->{contact}, 1);
358 $href .= "&contact=" . $form->escape($form->{contact});
359 $option .= "\n<br>" . $locale->text('Contact') . " : $form->{contact}";
361 if ($form->{"$form->{db}number"}) {
363 qq|&$form->{db}number=| . $form->escape($form->{"$form->{db}number"}, 1);
365 "&$form->{db}number=" . $form->escape($form->{"$form->{db}number"});
367 "\n<br>" . $locale->text('Number') . qq| : $form->{"$form->{db}number"}|;
369 if ($form->{email}) {
370 $callback .= "&email=" . $form->escape($form->{email}, 1);
371 $href .= "&email=" . $form->escape($form->{email});
372 $option .= "\n<br>" . $locale->text('E-mail') . " : $form->{email}";
375 $form->{callback} = "$callback&sort=$form->{sort}";
376 $callback = $form->escape($form->{callback});
379 qq|<th class=listheading>| . $locale->text('ID') . qq|</th>|;
380 $column_header{"$form->{db}number"} =
381 qq|<th><a class=listheading href=$href&sort=$form->{db}number>$number</a></th>|;
382 $column_header{name} =
383 qq|<th><a class=listheading href=$href&sort=name>|
384 . $locale->text('Name')
386 $column_header{address} =
387 qq|<th><a class=listheading href=$href&sort=address>|
388 . $locale->text('Address')
390 $column_header{contact} =
391 qq|<th><a class=listheading href=$href&sort=contact>|
392 . $locale->text('Contact')
394 $column_header{phone} =
395 qq|<th><a class=listheading href=$href&sort=phone>|
396 . $locale->text('Phone')
398 $column_header{fax} =
399 qq|<th><a class=listheading href=$href&sort=fax>|
400 . $locale->text('Fax')
402 $column_header{email} =
403 qq|<th><a class=listheading href=$href&sort=email>|
404 . $locale->text('E-mail')
407 qq|<th><a class=listheading href=$href&sort=cc>|
408 . $locale->text('Cc')
411 $column_header{taxnumber} =
412 qq|<th><a class=listheading href=$href&sort=taxnumber>|
413 . $locale->text('Tax Number')
415 $column_header{gifi_accno} =
416 qq|<th><a class=listheading href=$href&sort=gifi_accno>|
417 . $locale->text('GIFI')
419 $column_header{sic_code} =
420 qq|<th><a class=listheading href=$href&sort=sic_code>|
421 . $locale->text('SIC')
423 $column_header{business} =
424 qq|<th><a class=listheading href=$href&sort=business>|
425 . $locale->text('Type of Business')
428 $column_header{invnumber} =
429 qq|<th><a class=listheading href=$href&sort=invnumber>|
430 . $locale->text('Invoice')
432 $column_header{ordnumber} =
433 qq|<th><a class=listheading href=$href&sort=ordnumber>|
434 . $locale->text('Order')
436 $column_header{quonumber} =
437 qq|<th><a class=listheading href=$href&sort=quonumber>|
438 . $locale->text('Quotation')
441 $label = ucfirst $form->{db} . "s";
442 $form->{title} = $locale->text($label);
451 <th class=listtop>$form->{title}</th>
460 <tr class=listheading>
463 map { print "$column_header{$_}\n" } @column_index;
469 $ordertype = ($form->{db} eq 'customer') ? 'sales_order' : 'purchase_order';
471 ($form->{db} eq 'customer') ? 'sales_quotation' : 'request_quotation';
473 foreach $ref (@{ $form->{CT} }) {
475 if ($ref->{id} eq $sameid) {
476 map { $column_data{$_} = "<td> </td>" } @column_index;
478 map { $column_data{$_} = "<td>$ref->{$_} </td>" } @column_index;
480 map { $column_data{$_} = "<td>$ref->{$_} </td>" }
481 (invnumber, ordnumber, quonumber);
484 "<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>";
487 $email = $ref->{email};
488 $email =~ s/</\</;
489 $email =~ s/>/\>/;
491 $column_data{email} =
492 qq|<td><a href="mailto:$ref->{email}">$email</a></td>|;
497 if ($ref->{formtype} eq 'invoice') {
498 $column_data{invnumber} =
499 "<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>";
502 if ($ref->{formtype} eq 'order') {
503 $column_data{ordnumber} =
504 "<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>";
507 if ($ref->{formtype} eq 'quotation') {
508 $column_data{quonumber} =
509 "<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>";
518 map { print "$column_data{$_}\n" } @column_index;
524 $sameid = $ref->{id};
533 <td><hr size=3 noshade></td>
538 <form method=post action=$form->{script}>
540 <input name=callback type=hidden value="$form->{callback}">
541 <input name=db type=hidden value=$form->{db}>
543 <input type=hidden name=path value=$form->{path}>
544 <input type=hidden name=login value=$form->{login}>
545 <input type=hidden name=password value=$form->{password}>
547 <input class=submit type=submit name=action value="|
548 . $locale->text('Add') . qq|">
556 $lxdebug->leave_sub();
560 $lxdebug->enter_sub();
562 # show history button
563 $form->{javascript} = qq|<script type=text/javascript src=js/show_history.js></script>|;
564 #/show hhistory button
566 # $locale->text('Edit Customer')
567 # $locale->text('Edit Vendor')
569 CT->get_tuple(\%myconfig, \%$form);
571 # format " into "
572 map { $form->{$_} =~ s/\"/"/g } keys %$form;
574 $form->{title} = "Edit";
577 $form->{discount} *= 100;
582 $lxdebug->leave_sub();
586 $lxdebug->enter_sub();
588 $form->get_lists("employees" => "ALL_SALESMEN");
590 $form->{taxincluded} = ($form->{taxincluded}) ? "checked" : "";
591 $form->{creditlimit} =
592 $form->format_amount(\%myconfig, $form->{creditlimit}, 0);
593 $form->{discount} = $form->format_amount(\%myconfig, $form->{discount});
595 if ($myconfig{role} eq 'admin') {
598 <th align=right nowrap>| . $locale->text('Bcc') . qq|</th>
599 <td><input name=bcc size=35 value="$form->{bcc}"></td>
603 $form->{obsolete} = "checked" if $form->{obsolete};
605 $lang = qq|<option value=""></option>|;
606 foreach $item (@{ $form->{languages} }) {
607 if ($form->{language_id} eq $item->{id}) {
608 $lang .= qq|<option value="$item->{id}" selected>$item->{description}</option>|;
610 $lang .= qq|<option value="$item->{id}">$item->{description}</option>|;
614 $payment = qq|<option value=""></option>|;
615 foreach $item (@{ $form->{payment_terms} }) {
616 if ($form->{payment_id} eq $item->{id}) {
617 $payment .= qq|<option value="$item->{id}" selected>$item->{description}</option>|;
619 $payment .= qq|<option value="$item->{id}">$item->{description}</option>|;
624 if ($form->{db} eq "customer") {
625 $form->{taxzone_id} = 0;
627 $form->{taxzone_id} = 0;
631 if (@{ $form->{TAXZONE} }) {
632 foreach $item (@{ $form->{TAXZONE} }) {
633 if ($item->{id} == $form->{taxzone_id}) {
634 $form->{selecttaxzone} .=
635 "<option value=$item->{id} selected>$item->{description}\n";
637 $form->{selecttaxzone} .=
638 "<option value=$item->{id}>$item->{description}\n";
645 <th align=right>| . $locale->text('Steuersatz') . qq|</th>
646 <td><select name=taxzone_id>$form->{selecttaxzone}</select></td>
647 <input type=hidden name=selecttaxzone value="$form->{selecttaxzone}">
651 "$form->{script}?login=$form->{login}&path=$form->{path}&password=$form->{password}&action=get_contact";
653 my $pjx = new CGI::Ajax( 'get_contact' => $get_contact_url );
654 $form->{selectcontact} = "<option value=0></option>";
655 if (@{ $form->{CONTACTS} }) {
656 foreach $item (@{ $form->{CONTACTS} }) {
657 if ($item->{cp_id} == $form->{cp_id}) {
658 $form->{selectcontact} .=
659 qq|<option value=$item->{cp_id} selected>$item->{cp_name}</option>\n|;
661 $form->{selectcontact} .=
662 qq|<option value=$item->{cp_id}>$item->{cp_name}</option>\n|;
667 push(@ { $form->{AJAX} }, $pjx);
668 $ansprechpartner = qq|
670 <th align=right>| . $locale->text('Ansprechpartner') . qq|</th>
671 <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>
672 <input type=hidden name=selectcontact value="$form->{selectcontact}">
675 "$form->{script}?login=$form->{login}&path=$form->{path}&password=$form->{password}&action=get_shipto";
677 my $pjy = new CGI::Ajax( 'get_shipto' => $get_shipto_url );
678 $form->{selectshipto} = "<option value=0></option>";
679 $form->{selectshipto} .= "<option value=0>Alle</option>";
680 if (@{ $form->{SHIPTO} }) {
681 foreach $item (@{ $form->{SHIPTO} }) {
682 if ($item->{shipto_id} == $form->{shipto_id}) {
683 $form->{selectshipto} .=
684 "<option value=$item->{shipto_id} selected>$item->{shiptoname} $item->{shiptodepartment_1}\n";
686 $form->{selectshipto} .=
687 "<option value=$item->{shipto_id}>$item->{shiptoname} $item->{shiptodepartment_1}\n";
692 push(@ { $form->{AJAX} }, $pjy);
696 <th align=right>| . $locale->text('Shipping Address') . qq|</th>
697 <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>
698 <input type=hidden name=selectshipto value="$form->{selectshipto}">
703 "$form->{script}?login=$form->{login}&path=$form->{path}&password=$form->{password}&action=get_delivery";
705 my $pjz = new CGI::Ajax( 'get_delivery' => $get_delivery_url );
707 push(@ { $form->{AJAX} }, $pjz);
711 <th align=right>| . $locale->text('Shipping Address') . qq|</th>
712 <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>
715 foreach $item (split / /, $form->{taxaccounts}) {
716 if (($form->{tax}{$item}{taxable}) || !($form->{id})) {
718 qq| <input name="tax_$item" value=1 class=checkbox type=checkbox checked> <b>$form->{tax}{$item}{description}</b>|;
721 qq| <input name="tax_$item" value=1 class=checkbox type=checkbox> <b>$form->{tax}{$item}{description}</b>|;
731 <th align=right>| . $locale->text('Taxable') . qq|</th>
736 <td><input name=taxincluded class=checkbox type=checkbox value=1 $form->{taxincluded}></td>
737 <th align=left>| . $locale->text('Tax Included') . qq|</th>
744 $form->{selectbusiness} = qq|<option>\n|;
746 $form->{selectbusiness} .=
747 qq|<option value=$_->{id}>$_->{description}\n|
748 } @{ $form->{all_business} };
749 if ($form->{business_save}) {
750 $form->{selectbusiness} = $form->{business_save};
752 $form->{selectbusiness} =~
753 s/<option value=$form->{business}>/<option value=$form->{business} selected>/;
755 $label = ucfirst $form->{db};
756 if ($form->{title} eq "Edit") {
757 $form->{title} = $locale->text("$form->{title} $label") . " $form->{name}";
759 $form->{title} = $locale->text("$form->{title} $label");
761 if ($form->{title_save}) {
762 $form->{title} = $form->{title_save};
764 if ($form->{db} eq 'vendor') {
766 <th align=right>| . $locale->text('Kundennummer') . qq|</th>
767 <td><input name=v_customer_id size=10 tabindex=18 maxlength=35 value="$form->{v_customer_id}"></td>
771 if ($form->{db} eq 'customer') {
774 <th align=right>| . $locale->text('KNr. beim Kunden') . qq|</th>
775 <td><input name=c_vendor_id size=10 tabindex=18 maxlength=35 value="$form->{c_vendor_id}"></td>
780 <th align=right>| . $locale->text('Type of Business') . qq|</th>
781 <td><select name=business tabindex=22>$form->{selectbusiness}</select></td>
786 if ($form->{db} eq "customer") {
787 my (@salesman_values, %salesman_labels);
788 push(@salesman_values, undef);
789 foreach my $item (@{ $form->{ALL_SALESMEN} }) {
790 push(@salesman_values, $item->{id});
791 $salesman_labels{$item->{id}} = $item->{name} ne "" ? $item->{name} : $item->{login};
795 qq| <th align="right">| . $locale->text('Salesman') . qq|</th>
797 NTI($cgi->popup_menu('-name' => 'salesman_id', '-default' => $form->{salesman_id},
798 '-values' => \@salesman_values, '-labels' => \%salesman_labels))
802 ## LINET: Create a drop-down box with all prior titles and greetings.
803 CT->query_titles_and_greetings(\%myconfig, \%$form);
805 $select_title = qq| <select name=selected_cp_title><option></option>|;
806 map({ $select_title .= qq|<option>$_</option>|; } @{ $form->{TITLES} });
807 $select_title .= qq|</select>|;
810 qq| <select name=selected_cp_greeting><option></option>|;
812 { $select_greeting .= qq|<option>$_</option>|; } @{ $form->{GREETINGS} });
813 $select_greeting .= qq|</select>|;
815 $select_company_greeting =
816 qq| <select name=selected_company_greeting><option></option>|;
818 { $select_company_greeting .= qq|<option>$_</option>|; } @{ $form->{COMPANY_GREETINGS} });
819 $select_company_greeting .= qq|</select>|;
822 qq| <select name=selected_cp_abteilung><option></option>|;
824 { $select_department .= qq|<option>$_</option>|; } @{ $form->{DEPARTMENT} });
825 $select_department .= qq|</select>|;
828 if ($form->{db} eq 'customer') {
830 #get pricegroup and form it
831 $form->get_pricegroup(\%myconfig, { all => 1 });
833 $form->{pricegroup} = "$form->{klass}";
834 $form->{pricegroup_id} = "$form->{klass}";
836 if (@{ $form->{all_pricegroup} }) {
838 $form->{selectpricegroup} = qq|<option>\n|;
840 $form->{selectpricegroup} .=
841 qq|<option value="$_->{id}">$_->{pricegroup}\n|
842 } @{ $form->{all_pricegroup} };
845 if ($form->{selectpricegroup}) {
846 $form->{selectpricegroup} = $form->unescape($form->{selectpricegroup});
849 qq|<input type=hidden name=selectpricegroup value="|
850 . $form->escape($form->{selectpricegroup}, 1) . qq|">|;
852 $form->{selectpricegroup} =~
853 s/(<option value="\Q$form->{klass}\E")/$1 selected/;
856 qq|<select name=klass tabindex=24>$form->{selectpricegroup}</select>|;
861 # $locale->text('Customer Number')
862 # $locale->text('Vendor Number')
863 $form->{fokus} = "ct.greeting";
864 $form->{jsscript} = 1;
868 <body onLoad="fokus()">
871 <th class=listtop>$form->{title}</th>
876 <form method=post name="ct" action=$form->{script} onKeyUp="highlight(event)" onClick="highlight(event)">
880 <ul id="maintab" class="shadetabs">
881 <li class="selected"><a href="#" rel="billing">|
882 . $locale->text('Billing Address') . qq|</a></li>
883 <li><a href="#" rel="shipto">|
884 . $locale->text('Shipping Address') . qq|</a></li>
885 <li><a href="#" rel="contacts">Ansprechpartner</a></li>
886 <li><a href="#" rel="deliveries">|
887 . $locale->text('Lieferungen') . qq|</a></li>
891 <div class="tabcontentstyle">
893 <div id="billing" class="tabcontent">
898 <th align=right nowrap>| . $locale->text($label . ' Number') . qq|</th>
899 <td><input name="$form->{db}number" size=35 maxlength=35 value="$form->{"$form->{db}number"}"></td>
902 <th align=right nowrap>| . $locale->text('Greeting') . qq|</th>
903 <td><input id=greeting name=greeting size=30 maxlength=30 value="$form->{greeting}">
904 $select_company_greeting</td>
907 <th align=right nowrap>| . $locale->text('Company Name') . qq|</th>
908 <td><input name=name size=35 maxlength=75 value="$form->{name}"></td>
911 <th align=right nowrap>| . $locale->text('Abteilung') . qq|</th>
912 <td><input name=department_1 size=16 maxlength=75 value="$form->{department_1}">
913 <input name=department_2 size=16 maxlength=75 value="$form->{department_2}"></td>
916 <th align=right nowrap>| . $locale->text('Street') . qq|</th>
917 <td><input name=street size=35 maxlength=75 value="$form->{street}"></td>
920 <th align=right nowrap>|
921 . $locale->text('Zipcode') . "/" . $locale->text('City') . qq|</th>
922 <td><input name=zipcode size=5 maxlength=10 value="$form->{zipcode}">
923 <input name=city size=30 maxlength=75 value="$form->{city}"></td>
926 <th align=right nowrap>| . $locale->text('Country') . qq|</th>
927 <td><input name=country size=35 maxlength=75 value="$form->{country}"></td>
930 <th align=right nowrap>| . $locale->text('Contact') . qq|</th>
931 <td><input name=contact size=28 maxlength=75 value="$form->{contact}"></td>
934 <th align=right nowrap>| . $locale->text('Phone') . qq|</th>
935 <td><input name=phone size=30 maxlength=30 value="$form->{phone}"></td>
938 <th align=right nowrap>| . $locale->text('Fax') . qq|</th>
939 <td><input name=fax size=30 maxlength=30 value="$form->{fax}"></td>
942 <th align=right nowrap>| . $locale->text('E-mail') . qq|</th>
943 <td><input name=email size=45 value="$form->{email}"></td>
946 <th align=right nowrap>| . $locale->text('Homepage') . qq|</th>
947 <td><input name=homepage size=45 value="$form->{homepage}"></td>
952 <th align=right>| . $locale->text('Credit Limit') . qq|</th>
953 <td><input name=creditlimit size=9 value="$form->{creditlimit}"></td>
954 <input type="hidden" name="terms" value="$form->{terms}">
955 <th align=right>| . $locale->text('Payment Terms') . qq|</th>
956 <td><select name=payment_id>$payment</select></td>
957 <th align=right>| . $locale->text('Discount') . qq|</th>
958 <td><input name=discount size=4 value="$form->{discount}">
962 <th align=right>| . $locale->text('Tax Number / SSN') . qq|</th>
963 <td><input name=taxnumber size=20 value="$form->{taxnumber}"></td>
964 <th align=right>| . $locale->text('USt-IdNr.') . qq|</th>
965 <td><input name="ustid" maxlength="14" size="20" value="$form->{ustid}"></td>
969 <th align=right>| . $locale->text('Account Number') . qq|</th>
970 <td><input name=account_number size=10 value="$form->{account_number}"></td>
971 <th align=right>| . $locale->text('Bank Code Number') . qq|</th>
972 <td><input name=bank_code size=10 value="$form->{bank_code}"></td>
973 <th align=right>| . $locale->text('Bank') . qq|</th>
974 <td><input name=bank size=30 value="$form->{bank}"></td>
978 <th align=right>| . $locale->text('Language') . qq|</th>
979 <td><select name=language_id tabindex=23>$lang
982 if ($form->{db} eq 'customer') {
985 <th align=right>| . $locale->text('Preisklasse') . qq|</th>
986 <td>$pricegroup</td>|;
990 <td align=right>| . $locale->text('Obsolete') . qq|</td>
991 <td><input name=obsolete class=checkbox type=checkbox value=1 $form->{obsolete}></td>
1000 <th align=left nowrap>| . $locale->text('Notes') . qq|</th>
1003 <td><textarea name=notes rows=3 cols=60 wrap=soft>$form->{notes}</textarea></td>
1010 <br style="clear: left" /></div>|;
1013 <div id="shipto" class="tabcontent">
1018 <th align=right nowrap>| . $locale->text('Company Name') . qq|</th>
1019 <td><input id=shiptoname name=shiptoname size=35 maxlength=75 value="$form->{shiptoname}"></td>
1022 <th align=right nowrap>| . $locale->text('Abteilung') . qq|</th>
1023 <td><input id=shiptodepartment_1 name=shiptodepartment_1 size=16 maxlength=75 value="$form->{shiptodepartment_1}">
1024 <input id=shiptodepartment_2 name=shiptodepartment_2 size=16 maxlength=75 value="$form->{shiptodepartment_2}"></td>
1027 <th align=right nowrap>| . $locale->text('Street') . qq|</th>
1028 <td><input id=shiptostreet name=shiptostreet size=35 maxlength=75 value="$form->{shiptostreet}"></td>
1031 <th align=right nowrap>|
1032 . $locale->text('Zipcode') . "/" . $locale->text('City') . qq|</th>
1033 <td><input id=shiptozipcode name=shiptozipcode size=5 maxlength=10 value="$form->{shiptozipcode}">
1034 <input id=shiptocity name=shiptocity size=30 maxlength=75 value="$form->{shiptocity}"></td>
1037 <th align=right nowrap>| . $locale->text('Country') . qq|</th>
1038 <td><input id=shiptocountry name=shiptocountry size=35 maxlength=35 value="$form->{shiptocountry}"></td>
1041 <th align=right nowrap>| . $locale->text('Contact') . qq|</th>
1042 <td><input id=shiptocontact name=shiptocontact size=30 maxlength=75 value="$form->{shiptocontact}"></td>
1045 <th align=right nowrap>| . $locale->text('Phone') . qq|</th>
1046 <td><input id=shiptophone name=shiptophone size=30 maxlength=30 value="$form->{shiptophone}"></td>
1049 <th align=right nowrap>| . $locale->text('Fax') . qq|</th>
1050 <td><input id=shiptofax name=shiptofax size=30 maxlength=30 value="$form->{shiptofax}"></td>
1053 <th align=right nowrap>| . $locale->text('E-mail') . qq|</th>
1054 <td><input id=shiptoemail name=shiptoemail size=45 value="$form->{shiptoemail}"></td>
1064 <br style="clear: left" /></div>|;
1067 ##LINET - added fields for contact person
1069 <div id="contacts" class="tabcontent">
1073 <input type=hidden name=cp_id value=$form->{cp_id}>
1077 <th align=left nowrap>| . $locale->text('Greeting') . qq|</th>
1078 <td><input id=cp_greeting name=cp_greeting size=30 maxlength=30 value="$form->{cp_greeting}">
1079 $select_greeting</td>
1082 <th align=left nowrap>| . $locale->text('Title') . qq|</th>
1083 <td><input id=cp_title name=cp_title size=30 maxlength=30 value="$form->{cp_title}">
1087 <th align=left nowrap>| . $locale->text('Department') . qq|</th>
1088 <td><input id=cp_abteilung name=cp_abteilung size=30 maxlength=40 value="$form->{cp_abteilung}">
1089 $select_department</td>
1092 <th align=left nowrap>|
1093 . $locale->text('Given Name') . qq|</th>
1094 <td><input id=cp_givenname name=cp_givenname size=30 maxlength=40 value="$form->{cp_givenname}"></td>
1097 <th align=left nowrap>| . $locale->text('Name') . qq|</th>
1098 <td><input id=cp_name name=cp_name size=30 maxlength=40 value="$form->{cp_name}"></td>
1101 <th align=left nowrap>| . $locale->text('Phone1') . qq|</th>
1102 <td><input id=cp_phone1 name=cp_phone1 size=30 maxlength=30 value="$form->{cp_phone1}"></td>
1105 <th align=left nowrap>| . $locale->text('Phone2') . qq|</th>
1106 <td><input id=cp_phone2 name=cp_phone2 size=30 maxlength=30 value="$form->{cp_phone2}"></td>
1109 <th align=left nowrap>| . $locale->text('Fax') . qq|</th>
1110 <td><input id=cp_fax name=cp_fax size=30 maxlength=30 value="$form->{cp_fax}"></td>
1113 <th align=left nowrap>| . $locale->text('Mobile1') . qq|</th>
1114 <td><input id=cp_mobile1 name=cp_mobile1 size=30 maxlength=30 value="$form->{cp_mobile1}"></td>
1117 <th align=left nowrap>| . $locale->text('Mobile2') . qq|</th>
1118 <td><input id=cp_mobile2 name=cp_mobile2 size=30 maxlength=30 value="$form->{cp_mobile2}"></td>
1121 <th align=left nowrap>| . $locale->text('Sat. Phone') . qq|</th>
1122 <td><input id=cp_satphone name=cp_satphone size=30 maxlength=30 value="$form->{cp_satphone}"></td>
1125 <th align=left nowrap>| . $locale->text('Sat. Fax') . qq|</th>
1126 <td><input id=cp_satfax name=cp_satfax size=30 maxlength=30 value="$form->{cp_satfax}"></td>
1129 <th align=left nowrap>| . $locale->text('Project') . qq|</th>
1130 <td><input id=cp_project name=cp_project size=30 maxlength=40 value="$form->{cp_project}"></td>
1133 <th align=left nowrap>| . $locale->text('E-mail') . qq|</th>
1134 <td><input id=cp_email name=cp_email size=30 maxlength=40 value="$form->{cp_email}"></td>
1137 <th align=left nowrap>| . $locale->text('Private Phone') . qq|</th>
1138 <td><input id=cp_privatphone name=cp_privatphone size=30 maxlength=40 value="$form->{cp_privatphone}"></td>
1141 <th align=left nowrap>| . $locale->text('Private E-mail') . qq|</th>
1142 <td><input id=cp_privatemail name=cp_privatemail size=30 maxlength=40 value="$form->{cp_privatemail}"></td>
1145 <th align=left nowrap>| . $locale->text('Birthday') . qq|</th>
1146 <td><input id=cp_birthday name=cp_birthday size=30 maxlength=40 value="$form->{cp_birthday}"></td>
1152 <tr height="5"></tr>|;
1162 <br style="clear: left" /></div>
1163 <div id="deliveries" class="tabcontent">
1167 <th align=left nowrap>| . $locale->text('From') . qq|</th>
1168 <td><input id=from name=from size=10 maxlength=10 value="$form->{from}">
1169 <input type="button" name="fromB" id="trigger_from" value="?"></td>
1170 <th align=left nowrap>| . $locale->text('To (time)') . qq|</th>
1171 <td><input id=to name=to size=10 maxlength=10 value="$form->{to}">
1172 <input type="button" name="toB" id="trigger_to" value="?"></td>
1181 <br style="clear: left" /></div>
1185 | . $form->write_trigger(\%myconfig, 2, "fromB", "BL", "trigger_from",
1186 "toB", "BL", "trigger_to");
1188 $lxdebug->leave_sub();
1192 $lxdebug->enter_sub();
1194 $label = ucfirst $form->{db};
1196 ($form->{db} eq 'customer')
1197 ? $locale->text('Save and Quotation')
1198 : $locale->text('Save and RFQ');
1200 ($form->{db} eq 'customer')
1201 ? $locale->text('Save and AR Transaction')
1202 : $locale->text('Save and AP Transaction');
1204 ##<input class=submit type=submit name=action value="|.$locale->text("Save and Quotation").qq|">
1205 ##<input class=submit type=submit name=action value="|.$locale->text("Save and RFQ").qq|">
1206 ##<input class=submit type=submit name=action value="|.$locale->text("Save and AR Transaction").qq|">
1207 ##<input class=submit type=submit name=action value="|.$locale->text("Save and AP Transaction").qq|">
1210 <input name=id type=hidden id=cvid value=$form->{id}>
1211 <input name=taxaccounts type=hidden value="$form->{taxaccounts}">
1212 <input name=business_save type=hidden value="$form->{selectbusiness}">
1213 <input name=title_save type=hidden value="$form->{title}">
1215 <input type=hidden name=path value=$form->{path}>
1216 <input type=hidden name=login value=$form->{login}>
1217 <input type=hidden name=password value=$form->{password}>
1219 <input type=hidden name=callback value="$form->{callback}">
1220 <input type=hidden name=db id=db value=$form->{db}>
1225 <input class=submit type=submit name=action accesskey="s" value="|
1226 . $locale->text("Save") . qq|">
1227 <input class=submit type=submit name=action accesskey="s" value="|
1228 . $locale->text("Save and Close") . qq|">
1229 <input class=submit type=submit name=action value="$arap">
1230 <input class=submit type=submit name=action value="|
1231 . $locale->text("Save and Invoice") . qq|">
1232 <input class=submit type=submit name=action value="|
1233 . $locale->text("Save and Order") . qq|">
1234 <input class=submit type=submit name=action value="$quotation">
1237 if ($form->{id} && $form->{status} eq 'orphaned') {
1238 print qq|<input class=submit type=submit name=action value="|
1239 . $locale->text('Delete')
1243 # button for saving history
1244 if($form->{id} ne "") {
1246 <input type=button class=submit onclick=set_history_window(|
1248 . qq|); name=history id=history value=|
1249 . $locale->text('history')
1252 # /button for saving history
1257 <script type="text/javascript">
1258 //Start Tab Content script for UL with id="maintab" Separate multiple ids each with a comma.
1259 initializetabcontent("maintab")
1265 $lxdebug->leave_sub();
1268 sub add_transaction {
1269 $lxdebug->enter_sub();
1271 # # saving the history
1272 # if(!exists $form->{addition}) {
1273 # $form->{addition} = "ADD TRANSACTION";
1274 # $form->save_history($form->dbconnect(\%myconfig));
1276 # # /saving the history
1278 $form->isblank("name", $locale->text("Name missing!"));
1279 &{"CT::save_$form->{db}"}("", \%myconfig, \%$form);
1281 $form->{callback} = $form->escape($form->{callback}, 1);
1282 $name = $form->escape("$form->{name}", 1);
1285 "$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}";
1288 $lxdebug->leave_sub();
1291 sub save_and_ap_transaction {
1292 $lxdebug->enter_sub();
1294 $form->{script} = "ap.pl";
1295 # saving the history
1296 if(!exists $form->{addition}) {
1297 $form->{addition} = "SAVED";
1298 $form->save_history($form->dbconnect(\%myconfig));
1300 # /saving the history
1302 $lxdebug->leave_sub();
1305 sub save_and_ar_transaction {
1306 $lxdebug->enter_sub();
1308 $form->{script} = "ar.pl";
1309 # saving the history
1310 if(!exists $form->{addition}) {
1311 $form->{addition} = "SAVED";
1312 $form->save_history($form->dbconnect(\%myconfig));
1314 # /saving the history
1316 $lxdebug->leave_sub();
1319 sub save_and_invoice {
1320 $lxdebug->enter_sub();
1322 $form->{script} = ($form->{db} eq 'customer') ? "is.pl" : "ir.pl";
1323 $form->{type} = "invoice";
1324 # saving the history
1325 if(!exists $form->{addition}) {
1326 $form->{addition} = "SAVED";
1327 $form->save_history($form->dbconnect(\%myconfig));
1329 # /saving the history
1331 $lxdebug->leave_sub();
1335 $lxdebug->enter_sub();
1337 $form->{script} = "oe.pl";
1338 $form->{type} = "request_quotation";
1339 # saving the history
1340 if(!exists $form->{addition}) {
1341 $form->{addition} = "SAVED";
1342 $form->save_history($form->dbconnect(\%myconfig));
1344 # /saving the history
1346 $lxdebug->leave_sub();
1349 sub save_and_quotation {
1350 $lxdebug->enter_sub();
1352 $form->{script} = "oe.pl";
1353 $form->{type} = "sales_quotation";
1354 # saving the history
1355 if(!exists $form->{addition}) {
1356 $form->{addition} = "SAVED";
1357 $form->save_history($form->dbconnect(\%myconfig));
1359 # /saving the history
1361 $lxdebug->leave_sub();
1364 sub save_and_order {
1365 $lxdebug->enter_sub();
1367 $form->{script} = "oe.pl";
1369 ($form->{db} eq 'customer') ? "sales_order" : "purchase_order";
1370 # saving the history
1371 if(!exists $form->{addition}) {
1372 $form->{addition} = "SAVED";
1373 $form->save_history($form->dbconnect(\%myconfig));
1375 # /saving the history
1377 $lxdebug->leave_sub();
1380 sub save_and_close {
1381 $lxdebug->enter_sub();
1383 # $locale->text('Customer saved!')
1384 # $locale->text('Vendor saved!')
1386 $msg = ucfirst $form->{db};
1389 $form->isblank("name", $locale->text("Name missing!"));
1390 $rc = &{"CT::save_$form->{db}"}("", \%myconfig, \%$form);
1392 $form->error($locale->text('customernumber not unique!'));
1394 # saving the history
1395 if(!exists $form->{addition}) {
1396 $form->{addition} = "SAVED";
1397 $form->save_history($form->dbconnect(\%myconfig));
1399 # /saving the history
1400 $form->redirect($locale->text($msg));
1402 $lxdebug->leave_sub();
1406 $lxdebug->enter_sub();
1408 # $locale->text('Customer saved!')
1409 # $locale->text('Vendor saved!')
1411 $msg = ucfirst $form->{db};
1414 $form->isblank("name", $locale->text("Name missing!"));
1416 my $res = &{"CT::save_$form->{db}"}("", \%myconfig, \%$form);
1419 if ($form->{"db"} eq "customer") {
1420 $form->error($locale->text('This customer number is already in use.'));
1422 $form->error($locale->text('This vendor number is already in use.'));
1425 # saving the history
1426 if(!exists $form->{addition}) {
1427 $form->{addition} = "SAVED";
1428 $form->save_history($form->dbconnect(\%myconfig));
1430 # /saving the history
1433 $lxdebug->leave_sub();
1437 $lxdebug->enter_sub();
1439 # $locale->text('Customer deleted!')
1440 # $locale->text('Cannot delete customer!')
1441 # $locale->text('Vendor deleted!')
1442 # $locale->text('Cannot delete vendor!')
1444 CT->delete(\%myconfig, \%$form);
1446 $msg = ucfirst $form->{db};
1447 $msg .= " deleted!";
1448 # saving the history
1449 if(!exists $form->{addition}) {
1450 $form->{addition} = "DELETED";
1451 $form->save_history($form->dbconnect(\%myconfig));
1453 # /saving the history
1454 $form->redirect($locale->text($msg));
1456 $msg = "Cannot delete $form->{db}";
1457 $form->error($locale->text($msg));
1459 $lxdebug->leave_sub();
1463 $lxdebug->enter_sub();
1468 $lxdebug->leave_sub();
1472 $lxdebug->enter_sub();
1475 $lxdebug->leave_sub();
1479 $lxdebug->enter_sub();
1481 CT->get_contact(\%myconfig, \%$form);
1484 $result = "$form->{cp_name}";
1485 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);
1488 $lxdebug->leave_sub();
1493 $lxdebug->enter_sub();
1495 CT->get_shipto(\%myconfig, \%$form);
1498 $result = "$form->{shiptoname}";
1499 map { $result .= "__pjx__" . $form->{$_} } qw(shiptodepartment_1 shiptodepartment_2 shiptostreet shiptozipcode shiptocity shiptocountry shiptocontact shiptophone shiptofax shiptoemail);
1502 $lxdebug->leave_sub();
1507 $lxdebug->enter_sub();
1509 CT->get_delivery(\%myconfig, \%$form );
1512 $form->sort_columns(shiptoname,
1522 $column_header{shiptoname} =
1523 qq|<th class=listheading>| . $locale->text('Shipping Address') . qq|</th>|;
1524 $column_header{invnumber} =
1525 qq|<th class=listheading>|. $locale->text('Invoice'). qq|</th>|;
1526 $column_header{ordnumber} =
1527 qq|<th class=listheading>|. $locale->text('Order'). qq|</th>|;
1528 $column_header{transdate} =
1529 qq|<th class=listheading>| . $locale->text('Invdate') . qq|</th>|;
1530 $column_header{description} =
1531 qq|<th class=listheading>| . $locale->text('Description') . qq|</th>|;
1532 $column_header{qty} =
1533 qq|<th class=listheading>| . $locale->text('Qty') . qq|</th>|;
1534 $column_header{unit} =
1535 qq|<th class=listheading>| . $locale->text('Unit') . qq|</th>|;
1542 <tr class=listheading>
1545 map { $result .= "$column_header{$_}\n" } @column_index;
1552 foreach $ref (@{ $form->{DELIVERY} }) {
1554 if ($ref->{shiptoname} eq $sameshiptoname) {
1555 map { $column_data{$_} = "<td>$ref->{$_} </td>" } @column_index;
1556 $column_data{shiptoname} = "<td> </td>";
1558 map { $column_data{$_} = "<td>$ref->{$_} </td>" } @column_index;
1564 <tr class=listrow$i>
1567 map { $result .= "$column_data{$_}\n" } @column_index;
1573 $sameshiptoname = $ref->{shiptoname};
1585 $lxdebug->leave_sub();
1589 sub continue { &{ $form->{nextsub} } }