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->populate_drop_down_boxes(\%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);
570 CT->populate_drop_down_boxes(\%myconfig, \%$form);
572 # format " into "
573 map { $form->{$_} =~ s/\"/"/g } keys %$form;
575 $form->{title} = "Edit";
578 $form->{discount} *= 100;
583 $lxdebug->leave_sub();
587 $lxdebug->enter_sub();
589 $form->get_lists("employees" => "ALL_SALESMEN");
591 $form->{taxincluded} = ($form->{taxincluded}) ? "checked" : "";
592 $form->{creditlimit} =
593 $form->format_amount(\%myconfig, $form->{creditlimit}, 0);
594 $form->{discount} = $form->format_amount(\%myconfig, $form->{discount});
596 if ($myconfig{role} eq 'admin') {
599 <th align=right nowrap>| . $locale->text('Bcc') . qq|</th>
600 <td><input name=bcc size=35 value="$form->{bcc}"></td>
604 $form->{obsolete} = "checked" if $form->{obsolete};
606 $lang = qq|<option value=""></option>|;
607 foreach $item (@{ $form->{languages} }) {
608 if ($form->{language_id} eq $item->{id}) {
609 $lang .= qq|<option value="$item->{id}" selected>$item->{description}</option>|;
611 $lang .= qq|<option value="$item->{id}">$item->{description}</option>|;
615 $payment = qq|<option value=""></option>|;
616 foreach $item (@{ $form->{payment_terms} }) {
617 if ($form->{payment_id} eq $item->{id}) {
618 $payment .= qq|<option value="$item->{id}" selected>$item->{description}</option>|;
620 $payment .= qq|<option value="$item->{id}">$item->{description}</option>|;
625 if ($form->{db} eq "customer") {
626 $form->{taxzone_id} = 0;
628 $form->{taxzone_id} = 0;
632 if (@{ $form->{TAXZONE} }) {
633 foreach $item (@{ $form->{TAXZONE} }) {
634 if ($item->{id} == $form->{taxzone_id}) {
635 $form->{selecttaxzone} .=
636 "<option value=$item->{id} selected>$item->{description}\n";
638 $form->{selecttaxzone} .=
639 "<option value=$item->{id}>$item->{description}\n";
646 <th align=right>| . $locale->text('Steuersatz') . qq|</th>
647 <td><select name=taxzone_id>$form->{selecttaxzone}</select></td>
648 <input type=hidden name=selecttaxzone value="$form->{selecttaxzone}">
652 "$form->{script}?login=$form->{login}&path=$form->{path}&password=$form->{password}&action=get_contact";
654 my $pjx = new CGI::Ajax( 'get_contact' => $get_contact_url );
655 $form->{selectcontact} = "<option value=0></option>";
656 if (@{ $form->{CONTACTS} }) {
657 foreach $item (@{ $form->{CONTACTS} }) {
658 if ($item->{cp_id} == $form->{cp_id}) {
659 $form->{selectcontact} .=
660 qq|<option value=$item->{cp_id} selected>$item->{cp_name}</option>\n|;
662 $form->{selectcontact} .=
663 qq|<option value=$item->{cp_id}>$item->{cp_name}</option>\n|;
668 push(@ { $form->{AJAX} }, $pjx);
669 $ansprechpartner = qq|
671 <th align=right>| . $locale->text('Ansprechpartner') . qq|</th>
672 <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>
673 <input type=hidden name=selectcontact value="$form->{selectcontact}">
676 "$form->{script}?login=$form->{login}&path=$form->{path}&password=$form->{password}&action=get_shipto";
678 my $pjy = new CGI::Ajax( 'get_shipto' => $get_shipto_url );
679 $form->{selectshipto} = "<option value=0></option>";
680 $form->{selectshipto} .= "<option value=0>Alle</option>";
681 if (@{ $form->{SHIPTO} }) {
682 foreach $item (@{ $form->{SHIPTO} }) {
683 if ($item->{shipto_id} == $form->{shipto_id}) {
684 $form->{selectshipto} .=
685 "<option value=$item->{shipto_id} selected>$item->{shiptoname} $item->{shiptodepartment_1}\n";
687 $form->{selectshipto} .=
688 "<option value=$item->{shipto_id}>$item->{shiptoname} $item->{shiptodepartment_1}\n";
693 push(@ { $form->{AJAX} }, $pjy);
697 <th align=right>| . $locale->text('Shipping Address') . qq|</th>
698 <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>
699 <input type=hidden name=selectshipto value="$form->{selectshipto}">
704 "$form->{script}?login=$form->{login}&path=$form->{path}&password=$form->{password}&action=get_delivery";
706 my $pjz = new CGI::Ajax( 'get_delivery' => $get_delivery_url );
708 push(@ { $form->{AJAX} }, $pjz);
712 <th align=right>| . $locale->text('Shipping Address') . qq|</th>
713 <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>
716 $form->{selectbusiness} = qq|<option>\n|;
718 $form->{selectbusiness} .=
719 qq|<option value=$_->{id}>$_->{description}\n|
720 } @{ $form->{all_business} };
721 if ($form->{business_save}) {
722 $form->{selectbusiness} = $form->{business_save};
724 $form->{selectbusiness} =~
725 s/<option value=$form->{business}>/<option value=$form->{business} selected>/;
727 $label = ucfirst $form->{db};
728 if ($form->{title} eq "Edit") {
729 $form->{title} = $locale->text("$form->{title} $label") . " $form->{name}";
731 $form->{title} = $locale->text("$form->{title} $label");
733 if ($form->{title_save}) {
734 $form->{title} = $form->{title_save};
736 if ($form->{db} eq 'vendor') {
738 <th align=right>| . $locale->text('Kundennummer') . qq|</th>
739 <td><input name=v_customer_id size=10 tabindex=18 maxlength=35 value="$form->{v_customer_id}"></td>
743 if ($form->{db} eq 'customer') {
746 <th align=right>| . $locale->text('KNr. beim Kunden') . qq|</th>
747 <td><input name=c_vendor_id size=10 tabindex=18 maxlength=35 value="$form->{c_vendor_id}"></td>
752 <th align=right>| . $locale->text('Type of Business') . qq|</th>
753 <td><select name=business tabindex=22>$form->{selectbusiness}</select></td>
758 if ($form->{db} eq "customer") {
759 my (@salesman_values, %salesman_labels);
760 push(@salesman_values, undef);
761 foreach my $item (@{ $form->{ALL_SALESMEN} }) {
762 push(@salesman_values, $item->{id});
763 $salesman_labels{$item->{id}} = $item->{name} ne "" ? $item->{name} : $item->{login};
767 qq| <th align="right">| . $locale->text('Salesman') . qq|</th>
769 NTI($cgi->popup_menu('-name' => 'salesman_id', '-default' => $form->{salesman_id},
770 '-values' => \@salesman_values, '-labels' => \%salesman_labels))
774 ## LINET: Create a drop-down box with all prior titles and greetings.
775 CT->query_titles_and_greetings(\%myconfig, \%$form);
777 $select_title = qq| <select name=selected_cp_title><option></option>|;
778 map({ $select_title .= qq|<option>$_</option>|; } @{ $form->{TITLES} });
779 $select_title .= qq|</select>|;
782 qq| <select name=selected_cp_greeting><option></option>|;
784 { $select_greeting .= qq|<option>$_</option>|; } @{ $form->{GREETINGS} });
785 $select_greeting .= qq|</select>|;
787 $select_company_greeting =
788 qq| <select name=selected_company_greeting><option></option>|;
790 { $select_company_greeting .= qq|<option>$_</option>|; } @{ $form->{COMPANY_GREETINGS} });
791 $select_company_greeting .= qq|</select>|;
794 qq| <select name=selected_cp_abteilung><option></option>|;
796 { $select_department .= qq|<option>$_</option>|; } @{ $form->{DEPARTMENT} });
797 $select_department .= qq|</select>|;
800 if ($form->{db} eq 'customer') {
802 #get pricegroup and form it
803 $form->get_pricegroup(\%myconfig, { all => 1 });
805 $form->{pricegroup} = "$form->{klass}";
806 $form->{pricegroup_id} = "$form->{klass}";
808 if (@{ $form->{all_pricegroup} }) {
810 $form->{selectpricegroup} = qq|<option>\n|;
812 $form->{selectpricegroup} .=
813 qq|<option value="$_->{id}">$_->{pricegroup}\n|
814 } @{ $form->{all_pricegroup} };
817 if ($form->{selectpricegroup}) {
818 $form->{selectpricegroup} = $form->unescape($form->{selectpricegroup});
821 qq|<input type=hidden name=selectpricegroup value="|
822 . $form->escape($form->{selectpricegroup}, 1) . qq|">|;
824 $form->{selectpricegroup} =~
825 s/(<option value="\Q$form->{klass}\E")/$1 selected/;
828 qq|<select name=klass tabindex=24>$form->{selectpricegroup}</select>|;
833 # $locale->text('Customer Number')
834 # $locale->text('Vendor Number')
835 $form->{fokus} = "ct.greeting";
836 $form->{jsscript} = 1;
840 <body onLoad="fokus()">
843 <th class=listtop>$form->{title}</th>
848 <form method=post name="ct" action=$form->{script} onKeyUp="highlight(event)" onClick="highlight(event)">
852 <ul id="maintab" class="shadetabs">
853 <li class="selected"><a href="#" rel="billing">|
854 . $locale->text('Billing Address') . qq|</a></li>
855 <li><a href="#" rel="shipto">|
856 . $locale->text('Shipping Address') . qq|</a></li>
857 <li><a href="#" rel="contacts">Ansprechpartner</a></li>
858 <li><a href="#" rel="deliveries">|
859 . $locale->text('Lieferungen') . qq|</a></li>
863 <div class="tabcontentstyle">
865 <div id="billing" class="tabcontent">
870 <th align=right nowrap>| . $locale->text($label . ' Number') . qq|</th>
871 <td><input name="$form->{db}number" size=35 maxlength=35 value="$form->{"$form->{db}number"}"></td>
874 <th align=right nowrap>| . $locale->text('Greeting') . qq|</th>
875 <td><input id=greeting name=greeting size=30 maxlength=30 value="$form->{greeting}">
876 $select_company_greeting</td>
879 <th align=right nowrap>| . $locale->text('Company Name') . qq|</th>
880 <td><input name=name size=35 maxlength=75 value="$form->{name}"></td>
883 <th align=right nowrap>| . $locale->text('Abteilung') . qq|</th>
884 <td><input name=department_1 size=16 maxlength=75 value="$form->{department_1}">
885 <input name=department_2 size=16 maxlength=75 value="$form->{department_2}"></td>
888 <th align=right nowrap>| . $locale->text('Street') . qq|</th>
889 <td><input name=street size=35 maxlength=75 value="$form->{street}"></td>
892 <th align=right nowrap>|
893 . $locale->text('Zipcode') . "/" . $locale->text('City') . qq|</th>
894 <td><input name=zipcode size=5 maxlength=10 value="$form->{zipcode}">
895 <input name=city size=30 maxlength=75 value="$form->{city}"></td>
898 <th align=right nowrap>| . $locale->text('Country') . qq|</th>
899 <td><input name=country size=35 maxlength=75 value="$form->{country}"></td>
902 <th align=right nowrap>| . $locale->text('Contact') . qq|</th>
903 <td><input name=contact size=28 maxlength=75 value="$form->{contact}"></td>
906 <th align=right nowrap>| . $locale->text('Phone') . qq|</th>
907 <td><input name=phone size=30 maxlength=30 value="$form->{phone}"></td>
910 <th align=right nowrap>| . $locale->text('Fax') . qq|</th>
911 <td><input name=fax size=30 maxlength=30 value="$form->{fax}"></td>
914 <th align=right nowrap>| . $locale->text('E-mail') . qq|</th>
915 <td><input name=email size=45 value="$form->{email}"></td>
918 <th align=right nowrap>| . $locale->text('Homepage') . qq|</th>
919 <td><input name=homepage size=45 value="$form->{homepage}"></td>
924 <th align=right>| . $locale->text('Credit Limit') . qq|</th>
925 <td><input name=creditlimit size=9 value="$form->{creditlimit}"></td>
926 <input type="hidden" name="terms" value="$form->{terms}">
927 <th align=right>| . $locale->text('Payment Terms') . qq|</th>
928 <td><select name=payment_id>$payment</select></td>
929 <th align=right>| . $locale->text('Discount') . qq|</th>
930 <td><input name=discount size=4 value="$form->{discount}">
934 <th align=right>| . $locale->text('Tax Number / SSN') . qq|</th>
935 <td><input name=taxnumber size=20 value="$form->{taxnumber}"></td>
936 <th align=right>| . $locale->text('USt-IdNr.') . qq|</th>
937 <td><input name="ustid" maxlength="14" size="20" value="$form->{ustid}"></td>
941 <th align=right>| . $locale->text('Account Number') . qq|</th>
942 <td><input name=account_number size=10 value="$form->{account_number}"></td>
943 <th align=right>| . $locale->text('Bank Code Number') . qq|</th>
944 <td><input name=bank_code size=10 value="$form->{bank_code}"></td>
945 <th align=right>| . $locale->text('Bank') . qq|</th>
946 <td><input name=bank size=30 value="$form->{bank}"></td>
950 <th align=right>| . $locale->text('Language') . qq|</th>
951 <td><select name=language_id tabindex=23>$lang
954 if ($form->{db} eq 'customer') {
957 <th align=right>| . $locale->text('Preisklasse') . qq|</th>
958 <td>$pricegroup</td>|;
962 <td align=right>| . $locale->text('Obsolete') . qq|</td>
963 <td><input name=obsolete class=checkbox type=checkbox value=1 $form->{obsolete}></td>
972 <th align=left nowrap>| . $locale->text('Notes') . qq|</th>
975 <td><textarea name=notes rows=3 cols=60 wrap=soft>$form->{notes}</textarea></td>
982 <br style="clear: left" /></div>|;
985 <div id="shipto" class="tabcontent">
990 <th align=right nowrap>| . $locale->text('Company Name') . qq|</th>
991 <td><input id=shiptoname name=shiptoname size=35 maxlength=75 value="$form->{shiptoname}"></td>
994 <th align=right nowrap>| . $locale->text('Abteilung') . qq|</th>
995 <td><input id=shiptodepartment_1 name=shiptodepartment_1 size=16 maxlength=75 value="$form->{shiptodepartment_1}">
996 <input id=shiptodepartment_2 name=shiptodepartment_2 size=16 maxlength=75 value="$form->{shiptodepartment_2}"></td>
999 <th align=right nowrap>| . $locale->text('Street') . qq|</th>
1000 <td><input id=shiptostreet name=shiptostreet size=35 maxlength=75 value="$form->{shiptostreet}"></td>
1003 <th align=right nowrap>|
1004 . $locale->text('Zipcode') . "/" . $locale->text('City') . qq|</th>
1005 <td><input id=shiptozipcode name=shiptozipcode size=5 maxlength=10 value="$form->{shiptozipcode}">
1006 <input id=shiptocity name=shiptocity size=30 maxlength=75 value="$form->{shiptocity}"></td>
1009 <th align=right nowrap>| . $locale->text('Country') . qq|</th>
1010 <td><input id=shiptocountry name=shiptocountry size=35 maxlength=35 value="$form->{shiptocountry}"></td>
1013 <th align=right nowrap>| . $locale->text('Contact') . qq|</th>
1014 <td><input id=shiptocontact name=shiptocontact size=30 maxlength=75 value="$form->{shiptocontact}"></td>
1017 <th align=right nowrap>| . $locale->text('Phone') . qq|</th>
1018 <td><input id=shiptophone name=shiptophone size=30 maxlength=30 value="$form->{shiptophone}"></td>
1021 <th align=right nowrap>| . $locale->text('Fax') . qq|</th>
1022 <td><input id=shiptofax name=shiptofax size=30 maxlength=30 value="$form->{shiptofax}"></td>
1025 <th align=right nowrap>| . $locale->text('E-mail') . qq|</th>
1026 <td><input id=shiptoemail name=shiptoemail size=45 value="$form->{shiptoemail}"></td>
1036 <br style="clear: left" /></div>|;
1039 ##LINET - added fields for contact person
1041 <div id="contacts" class="tabcontent">
1045 <input type=hidden name=cp_id value=$form->{cp_id}>
1049 <th align=left nowrap>| . $locale->text('Greeting') . qq|</th>
1050 <td><input id=cp_greeting name=cp_greeting size=30 maxlength=30 value="$form->{cp_greeting}">
1051 $select_greeting</td>
1054 <th align=left nowrap>| . $locale->text('Title') . qq|</th>
1055 <td><input id=cp_title name=cp_title size=30 maxlength=30 value="$form->{cp_title}">
1059 <th align=left nowrap>| . $locale->text('Department') . qq|</th>
1060 <td><input id=cp_abteilung name=cp_abteilung size=30 maxlength=40 value="$form->{cp_abteilung}">
1061 $select_department</td>
1064 <th align=left nowrap>|
1065 . $locale->text('Given Name') . qq|</th>
1066 <td><input id=cp_givenname name=cp_givenname size=30 maxlength=40 value="$form->{cp_givenname}"></td>
1069 <th align=left nowrap>| . $locale->text('Name') . qq|</th>
1070 <td><input id=cp_name name=cp_name size=30 maxlength=40 value="$form->{cp_name}"></td>
1073 <th align=left nowrap>| . $locale->text('Phone1') . qq|</th>
1074 <td><input id=cp_phone1 name=cp_phone1 size=30 maxlength=30 value="$form->{cp_phone1}"></td>
1077 <th align=left nowrap>| . $locale->text('Phone2') . qq|</th>
1078 <td><input id=cp_phone2 name=cp_phone2 size=30 maxlength=30 value="$form->{cp_phone2}"></td>
1081 <th align=left nowrap>| . $locale->text('Fax') . qq|</th>
1082 <td><input id=cp_fax name=cp_fax size=30 maxlength=30 value="$form->{cp_fax}"></td>
1085 <th align=left nowrap>| . $locale->text('Mobile1') . qq|</th>
1086 <td><input id=cp_mobile1 name=cp_mobile1 size=30 maxlength=30 value="$form->{cp_mobile1}"></td>
1089 <th align=left nowrap>| . $locale->text('Mobile2') . qq|</th>
1090 <td><input id=cp_mobile2 name=cp_mobile2 size=30 maxlength=30 value="$form->{cp_mobile2}"></td>
1093 <th align=left nowrap>| . $locale->text('Sat. Phone') . qq|</th>
1094 <td><input id=cp_satphone name=cp_satphone size=30 maxlength=30 value="$form->{cp_satphone}"></td>
1097 <th align=left nowrap>| . $locale->text('Sat. Fax') . qq|</th>
1098 <td><input id=cp_satfax name=cp_satfax size=30 maxlength=30 value="$form->{cp_satfax}"></td>
1101 <th align=left nowrap>| . $locale->text('Project') . qq|</th>
1102 <td><input id=cp_project name=cp_project size=30 maxlength=40 value="$form->{cp_project}"></td>
1105 <th align=left nowrap>| . $locale->text('E-mail') . qq|</th>
1106 <td><input id=cp_email name=cp_email size=30 maxlength=40 value="$form->{cp_email}"></td>
1109 <th align=left nowrap>| . $locale->text('Private Phone') . qq|</th>
1110 <td><input id=cp_privatphone name=cp_privatphone size=30 maxlength=40 value="$form->{cp_privatphone}"></td>
1113 <th align=left nowrap>| . $locale->text('Private E-mail') . qq|</th>
1114 <td><input id=cp_privatemail name=cp_privatemail size=30 maxlength=40 value="$form->{cp_privatemail}"></td>
1117 <th align=left nowrap>| . $locale->text('Birthday') . qq|</th>
1118 <td><input id=cp_birthday name=cp_birthday size=30 maxlength=40 value="$form->{cp_birthday}"></td>
1124 <tr height="5"></tr>|;
1134 <br style="clear: left" /></div>
1135 <div id="deliveries" class="tabcontent">
1139 <th align=left nowrap>| . $locale->text('From') . qq|</th>
1140 <td><input id=from name=from size=10 maxlength=10 value="$form->{from}">
1141 <input type="button" name="fromB" id="trigger_from" value="?"></td>
1142 <th align=left nowrap>| . $locale->text('To (time)') . qq|</th>
1143 <td><input id=to name=to size=10 maxlength=10 value="$form->{to}">
1144 <input type="button" name="toB" id="trigger_to" value="?"></td>
1153 <br style="clear: left" /></div>
1157 | . $form->write_trigger(\%myconfig, 2, "fromB", "BL", "trigger_from",
1158 "toB", "BL", "trigger_to");
1160 $lxdebug->leave_sub();
1164 $lxdebug->enter_sub();
1166 $label = ucfirst $form->{db};
1168 ($form->{db} eq 'customer')
1169 ? $locale->text('Save and Quotation')
1170 : $locale->text('Save and RFQ');
1172 ($form->{db} eq 'customer')
1173 ? $locale->text('Save and AR Transaction')
1174 : $locale->text('Save and AP Transaction');
1176 ##<input class=submit type=submit name=action value="|.$locale->text("Save and Quotation").qq|">
1177 ##<input class=submit type=submit name=action value="|.$locale->text("Save and RFQ").qq|">
1178 ##<input class=submit type=submit name=action value="|.$locale->text("Save and AR Transaction").qq|">
1179 ##<input class=submit type=submit name=action value="|.$locale->text("Save and AP Transaction").qq|">
1182 <input name=id type=hidden id=cvid value=$form->{id}>
1183 <input name=business_save type=hidden value="$form->{selectbusiness}">
1184 <input name=title_save type=hidden value="$form->{title}">
1186 <input type=hidden name=path value=$form->{path}>
1187 <input type=hidden name=login value=$form->{login}>
1188 <input type=hidden name=password value=$form->{password}>
1190 <input type=hidden name=callback value="$form->{callback}">
1191 <input type=hidden name=db id=db value=$form->{db}>
1196 <input class=submit type=submit name=action accesskey="s" value="|
1197 . $locale->text("Save") . qq|">
1198 <input class=submit type=submit name=action accesskey="s" value="|
1199 . $locale->text("Save and Close") . qq|">
1200 <input class=submit type=submit name=action value="$arap">
1201 <input class=submit type=submit name=action value="|
1202 . $locale->text("Save and Invoice") . qq|">
1203 <input class=submit type=submit name=action value="|
1204 . $locale->text("Save and Order") . qq|">
1205 <input class=submit type=submit name=action value="$quotation">
1208 if ($form->{id} && $form->{status} eq 'orphaned') {
1209 print qq|<input class=submit type=submit name=action value="|
1210 . $locale->text('Delete')
1214 # button for saving history
1215 if($form->{id} ne "") {
1217 <input type=button class=submit onclick=set_history_window(|
1219 . qq|); name=history id=history value=|
1220 . $locale->text('history')
1223 # /button for saving history
1228 <script type="text/javascript">
1229 //Start Tab Content script for UL with id="maintab" Separate multiple ids each with a comma.
1230 initializetabcontent("maintab")
1236 $lxdebug->leave_sub();
1239 sub add_transaction {
1240 $lxdebug->enter_sub();
1242 # # saving the history
1243 # if(!exists $form->{addition}) {
1244 # $form->{addition} = "ADD TRANSACTION";
1245 # $form->save_history($form->dbconnect(\%myconfig));
1247 # # /saving the history
1249 $form->isblank("name", $locale->text("Name missing!"));
1250 &{"CT::save_$form->{db}"}("", \%myconfig, \%$form);
1252 $form->{callback} = $form->escape($form->{callback}, 1);
1253 $name = $form->escape("$form->{name}", 1);
1256 "$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}";
1259 $lxdebug->leave_sub();
1262 sub save_and_ap_transaction {
1263 $lxdebug->enter_sub();
1265 $form->{script} = "ap.pl";
1266 # saving the history
1267 if(!exists $form->{addition}) {
1268 $form->{addition} = "SAVED";
1269 $form->save_history($form->dbconnect(\%myconfig));
1271 # /saving the history
1273 $lxdebug->leave_sub();
1276 sub save_and_ar_transaction {
1277 $lxdebug->enter_sub();
1279 $form->{script} = "ar.pl";
1280 # saving the history
1281 if(!exists $form->{addition}) {
1282 $form->{addition} = "SAVED";
1283 $form->save_history($form->dbconnect(\%myconfig));
1285 # /saving the history
1287 $lxdebug->leave_sub();
1290 sub save_and_invoice {
1291 $lxdebug->enter_sub();
1293 $form->{script} = ($form->{db} eq 'customer') ? "is.pl" : "ir.pl";
1294 $form->{type} = "invoice";
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();
1306 $lxdebug->enter_sub();
1308 $form->{script} = "oe.pl";
1309 $form->{type} = "request_quotation";
1310 # saving the history
1311 if(!exists $form->{addition}) {
1312 $form->{addition} = "SAVED";
1313 $form->save_history($form->dbconnect(\%myconfig));
1315 # /saving the history
1317 $lxdebug->leave_sub();
1320 sub save_and_quotation {
1321 $lxdebug->enter_sub();
1323 $form->{script} = "oe.pl";
1324 $form->{type} = "sales_quotation";
1325 # saving the history
1326 if(!exists $form->{addition}) {
1327 $form->{addition} = "SAVED";
1328 $form->save_history($form->dbconnect(\%myconfig));
1330 # /saving the history
1332 $lxdebug->leave_sub();
1335 sub save_and_order {
1336 $lxdebug->enter_sub();
1338 $form->{script} = "oe.pl";
1340 ($form->{db} eq 'customer') ? "sales_order" : "purchase_order";
1341 # saving the history
1342 if(!exists $form->{addition}) {
1343 $form->{addition} = "SAVED";
1344 $form->save_history($form->dbconnect(\%myconfig));
1346 # /saving the history
1348 $lxdebug->leave_sub();
1351 sub save_and_close {
1352 $lxdebug->enter_sub();
1354 # $locale->text('Customer saved!')
1355 # $locale->text('Vendor saved!')
1357 $msg = ucfirst $form->{db};
1360 $form->isblank("name", $locale->text("Name missing!"));
1361 $rc = &{"CT::save_$form->{db}"}("", \%myconfig, \%$form);
1363 $form->error($locale->text('customernumber not unique!'));
1365 # saving the history
1366 if(!exists $form->{addition}) {
1367 $form->{addition} = "SAVED";
1368 $form->save_history($form->dbconnect(\%myconfig));
1370 # /saving the history
1371 $form->redirect($locale->text($msg));
1373 $lxdebug->leave_sub();
1377 $lxdebug->enter_sub();
1379 # $locale->text('Customer saved!')
1380 # $locale->text('Vendor saved!')
1382 $msg = ucfirst $form->{db};
1385 $form->isblank("name", $locale->text("Name missing!"));
1387 my $res = &{"CT::save_$form->{db}"}("", \%myconfig, \%$form);
1390 if ($form->{"db"} eq "customer") {
1391 $form->error($locale->text('This customer number is already in use.'));
1393 $form->error($locale->text('This vendor number is already in use.'));
1396 # saving the history
1397 if(!exists $form->{addition}) {
1398 $form->{addition} = "SAVED";
1399 $form->save_history($form->dbconnect(\%myconfig));
1401 # /saving the history
1404 $lxdebug->leave_sub();
1408 $lxdebug->enter_sub();
1410 # $locale->text('Customer deleted!')
1411 # $locale->text('Cannot delete customer!')
1412 # $locale->text('Vendor deleted!')
1413 # $locale->text('Cannot delete vendor!')
1415 CT->delete(\%myconfig, \%$form);
1417 $msg = ucfirst $form->{db};
1418 $msg .= " deleted!";
1419 # saving the history
1420 if(!exists $form->{addition}) {
1421 $form->{addition} = "DELETED";
1422 $form->save_history($form->dbconnect(\%myconfig));
1424 # /saving the history
1425 $form->redirect($locale->text($msg));
1427 $msg = "Cannot delete $form->{db}";
1428 $form->error($locale->text($msg));
1430 $lxdebug->leave_sub();
1434 $lxdebug->enter_sub();
1439 $lxdebug->leave_sub();
1443 $lxdebug->enter_sub();
1446 $lxdebug->leave_sub();
1450 $lxdebug->enter_sub();
1452 CT->get_contact(\%myconfig, \%$form);
1455 $result = "$form->{cp_name}";
1456 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);
1459 $lxdebug->leave_sub();
1464 $lxdebug->enter_sub();
1466 CT->get_shipto(\%myconfig, \%$form);
1469 $result = "$form->{shiptoname}";
1470 map { $result .= "__pjx__" . $form->{$_} } qw(shiptodepartment_1 shiptodepartment_2 shiptostreet shiptozipcode shiptocity shiptocountry shiptocontact shiptophone shiptofax shiptoemail);
1473 $lxdebug->leave_sub();
1478 $lxdebug->enter_sub();
1480 CT->get_delivery(\%myconfig, \%$form );
1483 $form->sort_columns(shiptoname,
1493 $column_header{shiptoname} =
1494 qq|<th class=listheading>| . $locale->text('Shipping Address') . qq|</th>|;
1495 $column_header{invnumber} =
1496 qq|<th class=listheading>|. $locale->text('Invoice'). qq|</th>|;
1497 $column_header{ordnumber} =
1498 qq|<th class=listheading>|. $locale->text('Order'). qq|</th>|;
1499 $column_header{transdate} =
1500 qq|<th class=listheading>| . $locale->text('Invdate') . qq|</th>|;
1501 $column_header{description} =
1502 qq|<th class=listheading>| . $locale->text('Description') . qq|</th>|;
1503 $column_header{qty} =
1504 qq|<th class=listheading>| . $locale->text('Qty') . qq|</th>|;
1505 $column_header{unit} =
1506 qq|<th class=listheading>| . $locale->text('Unit') . qq|</th>|;
1513 <tr class=listheading>
1516 map { $result .= "$column_header{$_}\n" } @column_index;
1523 foreach $ref (@{ $form->{DELIVERY} }) {
1525 if ($ref->{shiptoname} eq $sameshiptoname) {
1526 map { $column_data{$_} = "<td>$ref->{$_} </td>" } @column_index;
1527 $column_data{shiptoname} = "<td> </td>";
1529 map { $column_data{$_} = "<td>$ref->{$_} </td>" } @column_index;
1535 <tr class=listrow$i>
1538 map { $result .= "$column_data{$_}\n" } @column_index;
1544 $sameshiptoname = $ref->{shiptoname};
1556 $lxdebug->leave_sub();
1560 sub continue { &{ $form->{nextsub} } }