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");
79 <form method=post action=$form->{script}>
81 <input type=hidden name=db value=$form->{db}>
85 <th class=listtop>$form->{title}</th>
92 <th align=right nowrap>| . $locale->text($label . ' Number') . qq|</th>
93 <td><input name=$form->{db}number size=35></td>
96 <th align=right nowrap>| . $locale->text('Company Name') . qq|</th>
97 <td><input name=name size=35></td>
100 <th align=right nowrap>| . $locale->text('Contact') . qq|</th>
101 <td><input name=contact size=35></td>
104 <th align=right nowrap>| . $locale->text('E-mail') . qq|</th>
105 <td><input name=email size=35></td>
109 <td><input name=status class=radio type=radio value=all checked> |
110 . $locale->text('All') . qq|
111 <input name=status class=radio type=radio value=orphaned> |
112 . $locale->text('Orphaned') . qq|</td>
116 <td><input name="obsolete" class="radio" type="radio" value="all"> |
117 . $locale->text('All') . qq|
118 <input name="obsolete" class="radio" type="radio" value="Y"> |
119 . $locale->text('Obsolete') . qq|
120 <input name="obsolete" class="radio" type="radio" value="N" checked> |
121 . $locale->text('Not obsolete') . qq|</td>
124 <th align=right nowrap>| . $locale->text('Include in Report') . qq|</th>
128 <td><input name="l_id" type=checkbox class=checkbox value=Y> |
129 . $locale->text('ID') . qq|</td>
130 <td><input name="l_$form->{db}number" type=checkbox class=checkbox value=Y> |
131 . $locale->text($label . ' Number') . qq|</td>
132 <td><input name="l_name" type=checkbox class=checkbox value=Y checked> |
133 . $locale->text('Company Name') . qq|</td>
134 <td><input name="l_address" type=checkbox class=checkbox value=Y> |
135 . $locale->text('Address') . qq|</td>
138 <td><input name="l_contact" type=checkbox class=checkbox value=Y checked> |
139 . $locale->text('Contact') . qq|</td>
140 <td><input name="l_phone" type=checkbox class=checkbox value=Y checked> |
141 . $locale->text('Phone') . qq|</td>
142 <td><input name="l_fax" type=checkbox class=checkbox value=Y> |
143 . $locale->text('Fax') . qq|</td>
144 <td><input name="l_email" type=checkbox class=checkbox value=Y checked> |
145 . $locale->text('E-mail') . qq|</td>
148 <td><input name="l_taxnumber" type=checkbox class=checkbox value=Y> |
149 . $locale->text('Tax Number') . qq|</td>
150 <td><input name="l_sic_code" type=checkbox class=checkbox value=Y> |
151 . $locale->text('SIC') . qq|</td>
152 <td><input name="l_business" type=checkbox class=checkbox value=Y> |
153 . $locale->text('Type of Business') . qq|</td>
156 <td><input name="l_invnumber" type=checkbox class=checkbox value=Y> |
157 . $locale->text('Invoices') . qq|</td>
158 <td><input name="l_ordnumber" type=checkbox class=checkbox value=Y> |
159 . $locale->text('Orders') . qq|</td>
160 <td><input name="l_quonumber" type=checkbox class=checkbox value=Y> |
161 . $locale->text('Quotations') . qq|</td>
170 <td><hr size=3 noshade></td>
174 <input type=hidden name=nextsub value=list_names>
176 <input type=hidden name=path value=$form->{path}>
177 <input type=hidden name=login value=$form->{login}>
178 <input type=hidden name=password value=$form->{password}>
181 <input type=submit class=submit name=action value="|
182 . $locale->text('Continue') . qq|">
188 $lxdebug->leave_sub();
191 sub search_delivery {
192 $lxdebug->enter_sub();
194 $label = ucfirst $form->{db};
195 $form->{title} = $locale->text($label . "s");
202 <form method=post action=$form->{script}>
204 <input type=hidden name=db value=$form->{db}>
208 <th class=listtop>$form->{title}</th>
215 <th align=right nowrap>| . $locale->text($label . ' Number') . qq|</th>
216 <td><input name=$form->{db}number size=35></td>
219 <th align=right nowrap>| . $locale->text('Company Name') . qq|</th>
220 <td><input name=name size=35></td>
223 <th align=right nowrap>| . $locale->text('Contact') . qq|</th>
224 <td><input name=contact size=35></td>
227 <th align=right nowrap>| . $locale->text('E-mail') . qq|</th>
228 <td><input name=email size=35></td>
232 <td><input name=status class=radio type=radio value=all checked> |
233 . $locale->text('All') . qq|
234 <input name=status class=radio type=radio value=orphaned> |
235 . $locale->text('Orphaned') . qq|</td>
238 <th align=right nowrap>| . $locale->text('Include in Report') . qq|</th>
242 <td><input name="l_id" type=checkbox class=checkbox value=Y> |
243 . $locale->text('ID') . qq|</td>
244 <td><input name="l_$form->{db}number" type=checkbox class=checkbox value=Y> |
245 . $locale->text($label . ' Number') . qq|</td>
246 <td><input name="l_name" type=checkbox class=checkbox value=Y checked> |
247 . $locale->text('Company Name') . qq|</td>
248 <td><input name="l_address" type=checkbox class=checkbox value=Y> |
249 . $locale->text('Address') . qq|</td>
252 <td><input name="l_contact" type=checkbox class=checkbox value=Y checked> |
253 . $locale->text('Contact') . qq|</td>
254 <td><input name="l_phone" type=checkbox class=checkbox value=Y checked> |
255 . $locale->text('Phone') . qq|</td>
256 <td><input name="l_fax" type=checkbox class=checkbox value=Y> |
257 . $locale->text('Fax') . qq|</td>
258 <td><input name="l_email" type=checkbox class=checkbox value=Y checked> |
259 . $locale->text('E-mail') . qq|</td>
262 <td><input name="l_taxnumber" type=checkbox class=checkbox value=Y> |
263 . $locale->text('Tax Number') . qq|</td>
264 <td><input name="l_sic_code" type=checkbox class=checkbox value=Y> |
265 . $locale->text('SIC') . qq|</td>
266 <td><input name="l_business" type=checkbox class=checkbox value=Y> |
267 . $locale->text('Type of Business') . qq|</td>
270 <td><input name="l_invnumber" type=checkbox class=checkbox value=Y> |
271 . $locale->text('Invoices') . qq|</td>
272 <td><input name="l_ordnumber" type=checkbox class=checkbox value=Y> |
273 . $locale->text('Orders') . qq|</td>
274 <td><input name="l_quonumber" type=checkbox class=checkbox value=Y> |
275 . $locale->text('Quotations') . qq|</td>
284 <td><hr size=3 noshade></td>
288 <input type=hidden name=nextsub value=list_names>
290 <input type=hidden name=path value=$form->{path}>
291 <input type=hidden name=login value=$form->{login}>
292 <input type=hidden name=password value=$form->{password}>
295 <input type=submit class=submit name=action value="|
296 . $locale->text('Continue') . qq|">
302 $lxdebug->leave_sub();
306 $lxdebug->enter_sub();
308 CT->search(\%myconfig, \%$form);
311 "$form->{script}?action=list_names&db=$form->{db}&path=$form->{path}&login=$form->{login}&password=$form->{password}&status=$form->{status}&obsolete=$form->{obsolete}";
315 $form->sort_columns(id, name,
316 "$form->{db}number", address,
321 invnumber, ordnumber,
324 foreach $item (@columns) {
325 if ($form->{"l_$item"} eq "Y") {
326 push @column_index, $item;
328 # add column to href and callback
329 $callback .= "&l_$item=Y";
330 $href .= "&l_$item=Y";
334 ($form->{db} eq "customer")
335 ? $locale->text('Customer Number')
336 : $locale->text('Vendor Number');
338 if ($form->{status} eq 'all') {
339 $option = $locale->text('All');
341 if ($form->{status} eq 'orphaned') {
342 $option .= $locale->text('Orphaned');
345 $callback .= "&name=" . $form->escape($form->{name}, 1);
346 $href .= "&name=" . $form->escape($form->{name});
347 $option .= "\n<br>" . $locale->text('Name') . " : $form->{name}";
349 if ($form->{contact}) {
350 $callback .= "&contact=" . $form->escape($form->{contact}, 1);
351 $href .= "&contact=" . $form->escape($form->{contact});
352 $option .= "\n<br>" . $locale->text('Contact') . " : $form->{contact}";
354 if ($form->{"$form->{db}number"}) {
356 qq|&$form->{db}number=| . $form->escape($form->{"$form->{db}number"}, 1);
358 "&$form->{db}number=" . $form->escape($form->{"$form->{db}number"});
360 "\n<br>" . $locale->text('Number') . qq| : $form->{"$form->{db}number"}|;
362 if ($form->{email}) {
363 $callback .= "&email=" . $form->escape($form->{email}, 1);
364 $href .= "&email=" . $form->escape($form->{email});
365 $option .= "\n<br>" . $locale->text('E-mail') . " : $form->{email}";
368 $form->{callback} = "$callback&sort=$form->{sort}";
369 $callback = $form->escape($form->{callback});
372 qq|<th class=listheading>| . $locale->text('ID') . qq|</th>|;
373 $column_header{"$form->{db}number"} =
374 qq|<th><a class=listheading href=$href&sort=$form->{db}number>$number</a></th>|;
375 $column_header{name} =
376 qq|<th><a class=listheading href=$href&sort=name>|
377 . $locale->text('Name')
379 $column_header{address} =
380 qq|<th><a class=listheading href=$href&sort=address>|
381 . $locale->text('Address')
383 $column_header{contact} =
384 qq|<th><a class=listheading href=$href&sort=contact>|
385 . $locale->text('Contact')
387 $column_header{phone} =
388 qq|<th><a class=listheading href=$href&sort=phone>|
389 . $locale->text('Phone')
391 $column_header{fax} =
392 qq|<th><a class=listheading href=$href&sort=fax>|
393 . $locale->text('Fax')
395 $column_header{email} =
396 qq|<th><a class=listheading href=$href&sort=email>|
397 . $locale->text('E-mail')
400 qq|<th><a class=listheading href=$href&sort=cc>|
401 . $locale->text('Cc')
404 $column_header{taxnumber} =
405 qq|<th><a class=listheading href=$href&sort=taxnumber>|
406 . $locale->text('Tax Number')
408 $column_header{sic_code} =
409 qq|<th><a class=listheading href=$href&sort=sic_code>|
410 . $locale->text('SIC')
412 $column_header{business} =
413 qq|<th><a class=listheading href=$href&sort=business>|
414 . $locale->text('Type of Business')
417 $column_header{invnumber} =
418 qq|<th><a class=listheading href=$href&sort=invnumber>|
419 . $locale->text('Invoice')
421 $column_header{ordnumber} =
422 qq|<th><a class=listheading href=$href&sort=ordnumber>|
423 . $locale->text('Order')
425 $column_header{quonumber} =
426 qq|<th><a class=listheading href=$href&sort=quonumber>|
427 . $locale->text('Quotation')
430 $label = ucfirst $form->{db} . "s";
431 $form->{title} = $locale->text($label);
440 <th class=listtop>$form->{title}</th>
449 <tr class=listheading>
452 map { print "$column_header{$_}\n" } @column_index;
458 $ordertype = ($form->{db} eq 'customer') ? 'sales_order' : 'purchase_order';
460 ($form->{db} eq 'customer') ? 'sales_quotation' : 'request_quotation';
462 foreach $ref (@{ $form->{CT} }) {
464 if ($ref->{id} eq $sameid) {
465 map { $column_data{$_} = "<td> </td>" } @column_index;
467 map { $column_data{$_} = "<td>$ref->{$_} </td>" } @column_index;
469 map { $column_data{$_} = "<td>$ref->{$_} </td>" }
470 (invnumber, ordnumber, quonumber);
473 "<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>";
476 $email = $ref->{email};
477 $email =~ s/</\</;
478 $email =~ s/>/\>/;
480 $column_data{email} =
481 qq|<td><a href="mailto:$ref->{email}">$email</a></td>|;
486 if ($ref->{formtype} eq 'invoice') {
487 $column_data{invnumber} =
488 "<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>";
491 if ($ref->{formtype} eq 'order') {
492 $column_data{ordnumber} =
493 "<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>";
496 if ($ref->{formtype} eq 'quotation') {
497 $column_data{quonumber} =
498 "<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>";
507 map { print "$column_data{$_}\n" } @column_index;
513 $sameid = $ref->{id};
522 <td><hr size=3 noshade></td>
527 <form method=post action=$form->{script}>
529 <input name=callback type=hidden value="$form->{callback}">
530 <input name=db type=hidden value=$form->{db}>
532 <input type=hidden name=path value=$form->{path}>
533 <input type=hidden name=login value=$form->{login}>
534 <input type=hidden name=password value=$form->{password}>
536 <input class=submit type=submit name=action value="|
537 . $locale->text('Add') . qq|">
545 $lxdebug->leave_sub();
549 $lxdebug->enter_sub();
551 # show history button
552 $form->{javascript} = qq|<script type=text/javascript src=js/show_history.js></script>|;
553 #/show hhistory button
555 # $locale->text('Edit Customer')
556 # $locale->text('Edit Vendor')
558 CT->get_tuple(\%myconfig, \%$form);
559 CT->populate_drop_down_boxes(\%myconfig, \%$form);
561 # format " into "
562 map { $form->{$_} =~ s/\"/"/g } keys %$form;
564 $form->{title} = "Edit";
567 $form->{discount} *= 100;
572 $lxdebug->leave_sub();
576 $lxdebug->enter_sub();
578 $form->get_lists("employees" => "ALL_SALESMEN");
580 $form->{taxincluded} = ($form->{taxincluded}) ? "checked" : "";
581 $form->{creditlimit} =
582 $form->format_amount(\%myconfig, $form->{creditlimit}, 0);
583 $form->{discount} = $form->format_amount(\%myconfig, $form->{discount});
585 if ($myconfig{role} eq 'admin') {
588 <th align=right nowrap>| . $locale->text('Bcc') . qq|</th>
589 <td><input name=bcc size=35 value="$form->{bcc}"></td>
593 $form->{obsolete} = "checked" if $form->{obsolete};
595 $lang = qq|<option value=""></option>|;
596 foreach $item (@{ $form->{languages} }) {
597 if ($form->{language_id} eq $item->{id}) {
598 $lang .= qq|<option value="$item->{id}" selected>$item->{description}</option>|;
600 $lang .= qq|<option value="$item->{id}">$item->{description}</option>|;
604 $payment = qq|<option value=""></option>|;
605 foreach $item (@{ $form->{payment_terms} }) {
606 if ($form->{payment_id} eq $item->{id}) {
607 $payment .= qq|<option value="$item->{id}" selected>$item->{description}</option>|;
609 $payment .= qq|<option value="$item->{id}">$item->{description}</option>|;
614 if ($form->{db} eq "customer") {
615 $form->{taxzone_id} = 0;
617 $form->{taxzone_id} = 0;
621 if (@{ $form->{TAXZONE} }) {
622 foreach $item (@{ $form->{TAXZONE} }) {
623 if ($item->{id} == $form->{taxzone_id}) {
624 $form->{selecttaxzone} .=
625 "<option value=$item->{id} selected>$item->{description}\n";
627 $form->{selecttaxzone} .=
628 "<option value=$item->{id}>$item->{description}\n";
635 <th align=right>| . $locale->text('Steuersatz') . qq|</th>
636 <td><select name=taxzone_id>$form->{selecttaxzone}</select></td>
637 <input type=hidden name=selecttaxzone value="$form->{selecttaxzone}">
641 "$form->{script}?login=$form->{login}&path=$form->{path}&password=$form->{password}&action=get_contact";
643 my $pjx = new CGI::Ajax( 'get_contact' => $get_contact_url );
644 $form->{selectcontact} = "<option value=0></option>";
645 if (@{ $form->{CONTACTS} }) {
646 foreach $item (@{ $form->{CONTACTS} }) {
647 if ($item->{cp_id} == $form->{cp_id}) {
648 $form->{selectcontact} .=
649 qq|<option value=$item->{cp_id} selected>$item->{cp_name}</option>\n|;
651 $form->{selectcontact} .=
652 qq|<option value=$item->{cp_id}>$item->{cp_name}</option>\n|;
657 push(@ { $form->{AJAX} }, $pjx);
658 $ansprechpartner = qq|
660 <th align=right>| . $locale->text('Ansprechpartner') . qq|</th>
661 <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>
662 <input type=hidden name=selectcontact value="$form->{selectcontact}">
665 "$form->{script}?login=$form->{login}&path=$form->{path}&password=$form->{password}&action=get_shipto";
667 my $pjy = new CGI::Ajax( 'get_shipto' => $get_shipto_url );
668 $form->{selectshipto} = "<option value=0></option>";
669 $form->{selectshipto} .= "<option value=0>Alle</option>";
670 if (@{ $form->{SHIPTO} }) {
671 foreach $item (@{ $form->{SHIPTO} }) {
672 if ($item->{shipto_id} == $form->{shipto_id}) {
673 $form->{selectshipto} .=
674 "<option value=$item->{shipto_id} selected>$item->{shiptoname} $item->{shiptodepartment_1}\n";
676 $form->{selectshipto} .=
677 "<option value=$item->{shipto_id}>$item->{shiptoname} $item->{shiptodepartment_1}\n";
682 push(@ { $form->{AJAX} }, $pjy);
686 <th align=right>| . $locale->text('Shipping Address') . qq|</th>
687 <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>
688 <input type=hidden name=selectshipto value="$form->{selectshipto}">
693 "$form->{script}?login=$form->{login}&path=$form->{path}&password=$form->{password}&action=get_delivery";
695 my $pjz = new CGI::Ajax( 'get_delivery' => $get_delivery_url );
697 push(@ { $form->{AJAX} }, $pjz);
701 <th align=right>| . $locale->text('Shipping Address') . qq|</th>
702 <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>
705 $form->{selectbusiness} = qq|<option>\n|;
707 $form->{selectbusiness} .=
708 qq|<option value=$_->{id}>$_->{description}\n|
709 } @{ $form->{all_business} };
710 if ($form->{business_save}) {
711 $form->{selectbusiness} = $form->{business_save};
713 $form->{selectbusiness} =~
714 s/<option value=$form->{business}>/<option value=$form->{business} selected>/;
716 $label = ucfirst $form->{db};
717 if ($form->{title} eq "Edit") {
718 $form->{title} = $locale->text("$form->{title} $label") . " $form->{name}";
720 $form->{title} = $locale->text("$form->{title} $label");
722 if ($form->{title_save}) {
723 $form->{title} = $form->{title_save};
725 if ($form->{db} eq 'vendor') {
727 <th align=right>| . $locale->text('Kundennummer') . qq|</th>
728 <td><input name=v_customer_id size=10 maxlength=35 value="$form->{v_customer_id}"></td>
732 if ($form->{db} eq 'customer') {
735 <th align=right>| . $locale->text('KNr. beim Kunden') . qq|</th>
736 <td><input name=c_vendor_id size=10 maxlength=35 value="$form->{c_vendor_id}"></td>
741 <th align=right>| . $locale->text('Type of Business') . qq|</th>
742 <td><select name=business>$form->{selectbusiness}</select></td>
747 if ($form->{db} eq "customer") {
748 my (@salesman_values, %salesman_labels);
749 push(@salesman_values, undef);
750 foreach my $item (@{ $form->{ALL_SALESMEN} }) {
751 push(@salesman_values, $item->{id});
752 $salesman_labels{$item->{id}} = $item->{name} ne "" ? $item->{name} : $item->{login};
756 qq| <th align="right">| . $locale->text('Salesman') . qq|</th>
758 NTI($cgi->popup_menu('-name' => 'salesman_id', '-default' => $form->{salesman_id},
759 '-values' => \@salesman_values, '-labels' => \%salesman_labels))
763 ## LINET: Create a drop-down box with all prior titles and greetings.
764 CT->query_titles_and_greetings(\%myconfig, \%$form);
766 $select_title = qq| <select name=selected_cp_title><option></option>|;
767 map({ $select_title .= qq|<option>$_</option>|; } @{ $form->{TITLES} });
768 $select_title .= qq|</select>|;
771 qq| <select name=selected_cp_greeting><option></option>|;
773 { $select_greeting .= qq|<option>$_</option>|; } @{ $form->{GREETINGS} });
774 $select_greeting .= qq|</select>|;
776 $select_company_greeting =
777 qq| <select name=selected_company_greeting><option></option>|;
779 { $select_company_greeting .= qq|<option>$_</option>|; } @{ $form->{COMPANY_GREETINGS} });
780 $select_company_greeting .= qq|</select>|;
783 qq| <select name=selected_cp_abteilung><option></option>|;
785 { $select_department .= qq|<option>$_</option>|; } @{ $form->{DEPARTMENT} });
786 $select_department .= qq|</select>|;
789 if ($form->{db} eq 'customer') {
791 #get pricegroup and form it
792 $form->get_pricegroup(\%myconfig, { all => 1 });
794 $form->{pricegroup} = "$form->{klass}";
795 $form->{pricegroup_id} = "$form->{klass}";
797 if (@{ $form->{all_pricegroup} }) {
799 $form->{selectpricegroup} = qq|<option>\n|;
801 $form->{selectpricegroup} .=
802 qq|<option value="$_->{id}">$_->{pricegroup}\n|
803 } @{ $form->{all_pricegroup} };
806 if ($form->{selectpricegroup}) {
807 $form->{selectpricegroup} = $form->unescape($form->{selectpricegroup});
810 qq|<input type=hidden name=selectpricegroup value="|
811 . $form->escape($form->{selectpricegroup}, 1) . qq|">|;
813 $form->{selectpricegroup} =~
814 s/(<option value="\Q$form->{klass}\E")/$1 selected/;
817 qq|<select name=klass>$form->{selectpricegroup}</select>|;
822 # $locale->text('Customer Number')
823 # $locale->text('Vendor Number')
824 $form->{fokus} = "ct.greeting";
825 $form->{jsscript} = 1;
829 <body onLoad="fokus()">
832 <th class=listtop>$form->{title}</th>
837 <form method=post name="ct" action=$form->{script} onKeyUp="highlight(event)" onClick="highlight(event)">
841 <ul id="maintab" class="shadetabs">
842 <li class="selected"><a href="#" rel="billing">|
843 . $locale->text('Billing Address') . qq|</a></li>
844 <li><a href="#" rel="shipto">|
845 . $locale->text('Shipping Address') . qq|</a></li>
846 <li><a href="#" rel="contacts">Ansprechpartner</a></li>
847 <li><a href="#" rel="deliveries">|
848 . $locale->text('Lieferungen') . qq|</a></li>
852 <div class="tabcontentstyle">
854 <div id="billing" class="tabcontent">
859 <th align=right nowrap>| . $locale->text($label . ' Number') . qq|</th>
860 <td><input name="$form->{db}number" size=35 maxlength=35 value="$form->{"$form->{db}number"}"></td>
863 <th align=right nowrap>| . $locale->text('Greeting') . qq|</th>
864 <td><input id=greeting name=greeting size=30 maxlength=30 value="$form->{greeting}">
865 $select_company_greeting</td>
868 <th align=right nowrap>| . $locale->text('Company Name') . qq|</th>
869 <td><input name=name size=35 maxlength=75 value="$form->{name}"></td>
872 <th align=right nowrap>| . $locale->text('Abteilung') . qq|</th>
873 <td><input name=department_1 size=16 maxlength=75 value="$form->{department_1}">
874 <input name=department_2 size=16 maxlength=75 value="$form->{department_2}"></td>
877 <th align=right nowrap>| . $locale->text('Street') . qq|</th>
878 <td><input name=street size=35 maxlength=75 value="$form->{street}"></td>
881 <th align=right nowrap>|
882 . $locale->text('Zipcode') . "/" . $locale->text('City') . qq|</th>
883 <td><input name=zipcode size=5 maxlength=10 value="$form->{zipcode}">
884 <input name=city size=30 maxlength=75 value="$form->{city}"></td>
887 <th align=right nowrap>| . $locale->text('Country') . qq|</th>
888 <td><input name=country size=35 maxlength=75 value="$form->{country}"></td>
891 <th align=right nowrap>| . $locale->text('Contact') . qq|</th>
892 <td><input name=contact size=28 maxlength=75 value="$form->{contact}"></td>
895 <th align=right nowrap>| . $locale->text('Phone') . qq|</th>
896 <td><input name=phone size=30 maxlength=30 value="$form->{phone}"></td>
899 <th align=right nowrap>| . $locale->text('Fax') . qq|</th>
900 <td><input name=fax size=30 maxlength=30 value="$form->{fax}"></td>
903 <th align=right nowrap>| . $locale->text('E-mail') . qq|</th>
904 <td><input name=email size=45 value="$form->{email}"></td>
907 <th align=right nowrap>| . $locale->text('Homepage') . qq|</th>
908 <td><input name=homepage size=45 value="$form->{homepage}"></td>
913 <th align=right>| . $locale->text('Credit Limit') . qq|</th>
914 <td><input name=creditlimit size=9 value="$form->{creditlimit}"></td>
915 <input type="hidden" name="terms" value="$form->{terms}">
916 <th align=right>| . $locale->text('Payment Terms') . qq|</th>
917 <td><select name=payment_id>$payment</select></td>
918 <th align=right>| . $locale->text('Discount') . qq|</th>
919 <td><input name=discount size=4 value="$form->{discount}">
923 <th align=right>| . $locale->text('Tax Number / SSN') . qq|</th>
924 <td><input name=taxnumber size=20 value="$form->{taxnumber}"></td>
925 <th align=right>| . $locale->text('USt-IdNr.') . qq|</th>
926 <td><input name="ustid" maxlength="14" size="20" value="$form->{ustid}"></td>
930 <th align=right>| . $locale->text('Account Number') . qq|</th>
931 <td><input name=account_number size=10 value="$form->{account_number}"></td>
932 <th align=right>| . $locale->text('Bank Code Number') . qq|</th>
933 <td><input name=bank_code size=10 value="$form->{bank_code}"></td>
934 <th align=right>| . $locale->text('Bank') . qq|</th>
935 <td><input name=bank size=30 value="$form->{bank}"></td>
939 <th align=right>| . $locale->text('Language') . qq|</th>
940 <td><select name=language_id>$lang
943 if ($form->{db} eq 'customer') {
946 <th align=right>| . $locale->text('Preisklasse') . qq|</th>
947 <td>$pricegroup</td>|;
951 <td align=right>| . $locale->text('Obsolete') . qq|</td>
952 <td><input name=obsolete class=checkbox type=checkbox value=1 $form->{obsolete}></td>
961 <th align=left nowrap>| . $locale->text('Notes') . qq|</th>
964 <td><textarea name=notes rows=3 cols=60 wrap=soft>$form->{notes}</textarea></td>
971 <br style="clear: left" /></div>|;
974 <div id="shipto" class="tabcontent">
979 <th align=right nowrap>| . $locale->text('Company Name') . qq|</th>
980 <td><input id=shiptoname name=shiptoname size=35 maxlength=75 value="$form->{shiptoname}"></td>
983 <th align=right nowrap>| . $locale->text('Abteilung') . qq|</th>
984 <td><input id=shiptodepartment_1 name=shiptodepartment_1 size=16 maxlength=75 value="$form->{shiptodepartment_1}">
985 <input id=shiptodepartment_2 name=shiptodepartment_2 size=16 maxlength=75 value="$form->{shiptodepartment_2}"></td>
988 <th align=right nowrap>| . $locale->text('Street') . qq|</th>
989 <td><input id=shiptostreet name=shiptostreet size=35 maxlength=75 value="$form->{shiptostreet}"></td>
992 <th align=right nowrap>|
993 . $locale->text('Zipcode') . "/" . $locale->text('City') . qq|</th>
994 <td><input id=shiptozipcode name=shiptozipcode size=5 maxlength=10 value="$form->{shiptozipcode}">
995 <input id=shiptocity name=shiptocity size=30 maxlength=75 value="$form->{shiptocity}"></td>
998 <th align=right nowrap>| . $locale->text('Country') . qq|</th>
999 <td><input id=shiptocountry name=shiptocountry size=35 maxlength=35 value="$form->{shiptocountry}"></td>
1002 <th align=right nowrap>| . $locale->text('Contact') . qq|</th>
1003 <td><input id=shiptocontact name=shiptocontact size=30 maxlength=75 value="$form->{shiptocontact}"></td>
1006 <th align=right nowrap>| . $locale->text('Phone') . qq|</th>
1007 <td><input id=shiptophone name=shiptophone size=30 maxlength=30 value="$form->{shiptophone}"></td>
1010 <th align=right nowrap>| . $locale->text('Fax') . qq|</th>
1011 <td><input id=shiptofax name=shiptofax size=30 maxlength=30 value="$form->{shiptofax}"></td>
1014 <th align=right nowrap>| . $locale->text('E-mail') . qq|</th>
1015 <td><input id=shiptoemail name=shiptoemail size=45 value="$form->{shiptoemail}"></td>
1025 <br style="clear: left" /></div>|;
1028 ##LINET - added fields for contact person
1030 <div id="contacts" class="tabcontent">
1034 <input type=hidden name=cp_id value=$form->{cp_id}>
1038 <th align=left nowrap>| . $locale->text('Greeting') . qq|</th>
1039 <td><input id=cp_greeting name=cp_greeting size=40 maxlength=40 value="$form->{cp_greeting}">
1040 $select_greeting</td>
1043 <th align=left nowrap>| . $locale->text('Title') . qq|</th>
1044 <td><input id=cp_title name=cp_title size=40 maxlength=40 value="$form->{cp_title}">
1048 <th align=left nowrap>| . $locale->text('Department') . qq|</th>
1049 <td><input id=cp_abteilung name=cp_abteilung size=40 maxlength=40 value="$form->{cp_abteilung}">
1050 $select_department</td>
1053 <th align=left nowrap>|
1054 . $locale->text('Given Name') . qq|</th>
1055 <td><input id=cp_givenname name=cp_givenname size=40 maxlength=40 value="$form->{cp_givenname}"></td>
1058 <th align=left nowrap>| . $locale->text('Name') . qq|</th>
1059 <td><input id=cp_name name=cp_name size=40 maxlength=40 value="$form->{cp_name}"></td>
1062 <th align=left nowrap>| . $locale->text('Phone1') . qq|</th>
1063 <td><input id=cp_phone1 name=cp_phone1 size=40 maxlength=40 value="$form->{cp_phone1}"></td>
1066 <th align=left nowrap>| . $locale->text('Phone2') . qq|</th>
1067 <td><input id=cp_phone2 name=cp_phone2 size=40 maxlength=40 value="$form->{cp_phone2}"></td>
1070 <th align=left nowrap>| . $locale->text('Fax') . qq|</th>
1071 <td><input id=cp_fax name=cp_fax size=40 maxlength=40 value="$form->{cp_fax}"></td>
1074 <th align=left nowrap>| . $locale->text('Mobile1') . qq|</th>
1075 <td><input id=cp_mobile1 name=cp_mobile1 size=40 maxlength=40 value="$form->{cp_mobile1}"></td>
1078 <th align=left nowrap>| . $locale->text('Mobile2') . qq|</th>
1079 <td><input id=cp_mobile2 name=cp_mobile2 size=40 maxlength=40 value="$form->{cp_mobile2}"></td>
1082 <th align=left nowrap>| . $locale->text('Sat. Phone') . qq|</th>
1083 <td><input id=cp_satphone name=cp_satphone size=40 maxlength=40 value="$form->{cp_satphone}"></td>
1086 <th align=left nowrap>| . $locale->text('Sat. Fax') . qq|</th>
1087 <td><input id=cp_satfax name=cp_satfax size=40 maxlength=40 value="$form->{cp_satfax}"></td>
1090 <th align=left nowrap>| . $locale->text('Project') . qq|</th>
1091 <td><input id=cp_project name=cp_project size=40 maxlength=40 value="$form->{cp_project}"></td>
1094 <th align=left nowrap>| . $locale->text('E-mail') . qq|</th>
1095 <td><input id=cp_email name=cp_email size=40 maxlength=40 value="$form->{cp_email}"></td>
1098 <th align=left nowrap>| . $locale->text('Private Phone') . qq|</th>
1099 <td><input id=cp_privatphone name=cp_privatphone size=40 maxlength=40 value="$form->{cp_privatphone}"></td>
1102 <th align=left nowrap>| . $locale->text('Private E-mail') . qq|</th>
1103 <td><input id=cp_privatemail name=cp_privatemail size=40 maxlength=40 value="$form->{cp_privatemail}"></td>
1106 <th align=left nowrap>| . $locale->text('Birthday') . qq|</th>
1107 <td><input id=cp_birthday name=cp_birthday size=40 maxlength=40 value="$form->{cp_birthday}"></td>
1113 <tr height="5"></tr>|;
1123 <br style="clear: left" /></div>
1124 <div id="deliveries" class="tabcontent">
1128 <th align=left nowrap>| . $locale->text('From') . qq|</th>
1129 <td><input id=from name=from size=10 maxlength=10 value="$form->{from}">
1130 <input type="button" name="fromB" id="trigger_from" value="?"></td>
1131 <th align=left nowrap>| . $locale->text('To (time)') . qq|</th>
1132 <td><input id=to name=to size=10 maxlength=10 value="$form->{to}">
1133 <input type="button" name="toB" id="trigger_to" value="?"></td>
1142 <br style="clear: left" /></div>
1146 | . $form->write_trigger(\%myconfig, 2, "fromB", "BL", "trigger_from",
1147 "toB", "BL", "trigger_to");
1149 $lxdebug->leave_sub();
1153 $lxdebug->enter_sub();
1155 $label = ucfirst $form->{db};
1157 ($form->{db} eq 'customer')
1158 ? $locale->text('Save and Quotation')
1159 : $locale->text('Save and RFQ');
1161 ($form->{db} eq 'customer')
1162 ? $locale->text('Save and AR Transaction')
1163 : $locale->text('Save and AP Transaction');
1165 ##<input class=submit type=submit name=action value="|.$locale->text("Save and Quotation").qq|">
1166 ##<input class=submit type=submit name=action value="|.$locale->text("Save and RFQ").qq|">
1167 ##<input class=submit type=submit name=action value="|.$locale->text("Save and AR Transaction").qq|">
1168 ##<input class=submit type=submit name=action value="|.$locale->text("Save and AP Transaction").qq|">
1171 <input name=id type=hidden id=cvid value=$form->{id}>
1172 <input name=business_save type=hidden value="$form->{selectbusiness}">
1173 <input name=title_save type=hidden value="$form->{title}">
1175 <input type=hidden name=path value=$form->{path}>
1176 <input type=hidden name=login value=$form->{login}>
1177 <input type=hidden name=password value=$form->{password}>
1179 <input type=hidden name=callback value="$form->{callback}">
1180 <input type=hidden name=db id=db value=$form->{db}>
1185 <input class=submit type=submit name=action accesskey="s" value="|
1186 . $locale->text("Save") . qq|">
1187 <input class=submit type=submit name=action accesskey="s" value="|
1188 . $locale->text("Save and Close") . qq|">
1189 <input class=submit type=submit name=action value="$arap">
1190 <input class=submit type=submit name=action value="|
1191 . $locale->text("Save and Invoice") . qq|">
1192 <input class=submit type=submit name=action value="|
1193 . $locale->text("Save and Order") . qq|">
1194 <input class=submit type=submit name=action value="$quotation">
1197 if ($form->{id} && $form->{status} eq 'orphaned') {
1198 print qq|<input class=submit type=submit name=action value="|
1199 . $locale->text('Delete')
1203 # button for saving history
1204 if($form->{id} ne "") {
1206 <input type=button class=submit onclick=set_history_window(|
1208 . qq|); name=history id=history value=|
1209 . $locale->text('history')
1212 # /button for saving history
1217 <script type="text/javascript">
1218 //Start Tab Content script for UL with id="maintab" Separate multiple ids each with a comma.
1219 initializetabcontent("maintab")
1225 $lxdebug->leave_sub();
1228 sub add_transaction {
1229 $lxdebug->enter_sub();
1231 # # saving the history
1232 # if(!exists $form->{addition}) {
1233 # $form->{addition} = "ADD TRANSACTION";
1234 # $form->save_history($form->dbconnect(\%myconfig));
1236 # # /saving the history
1238 $form->isblank("name", $locale->text("Name missing!"));
1239 &{"CT::save_$form->{db}"}("", \%myconfig, \%$form);
1241 $form->{callback} = $form->escape($form->{callback}, 1);
1242 $name = $form->escape("$form->{name}", 1);
1245 "$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}";
1248 $lxdebug->leave_sub();
1251 sub save_and_ap_transaction {
1252 $lxdebug->enter_sub();
1254 $form->{script} = "ap.pl";
1255 # saving the history
1256 if(!exists $form->{addition}) {
1257 $form->{addition} = "SAVED";
1258 $form->save_history($form->dbconnect(\%myconfig));
1260 # /saving the history
1262 $lxdebug->leave_sub();
1265 sub save_and_ar_transaction {
1266 $lxdebug->enter_sub();
1268 $form->{script} = "ar.pl";
1269 # saving the history
1270 if(!exists $form->{addition}) {
1271 $form->{addition} = "SAVED";
1272 $form->save_history($form->dbconnect(\%myconfig));
1274 # /saving the history
1276 $lxdebug->leave_sub();
1279 sub save_and_invoice {
1280 $lxdebug->enter_sub();
1282 $form->{script} = ($form->{db} eq 'customer') ? "is.pl" : "ir.pl";
1283 $form->{type} = "invoice";
1284 # saving the history
1285 if(!exists $form->{addition}) {
1286 $form->{addition} = "SAVED";
1287 $form->save_history($form->dbconnect(\%myconfig));
1289 # /saving the history
1291 $lxdebug->leave_sub();
1295 $lxdebug->enter_sub();
1297 $form->{script} = "oe.pl";
1298 $form->{type} = "request_quotation";
1299 # saving the history
1300 if(!exists $form->{addition}) {
1301 $form->{addition} = "SAVED";
1302 $form->save_history($form->dbconnect(\%myconfig));
1304 # /saving the history
1306 $lxdebug->leave_sub();
1309 sub save_and_quotation {
1310 $lxdebug->enter_sub();
1312 $form->{script} = "oe.pl";
1313 $form->{type} = "sales_quotation";
1314 # saving the history
1315 if(!exists $form->{addition}) {
1316 $form->{addition} = "SAVED";
1317 $form->save_history($form->dbconnect(\%myconfig));
1319 # /saving the history
1321 $lxdebug->leave_sub();
1324 sub save_and_order {
1325 $lxdebug->enter_sub();
1327 $form->{script} = "oe.pl";
1329 ($form->{db} eq 'customer') ? "sales_order" : "purchase_order";
1330 # saving the history
1331 if(!exists $form->{addition}) {
1332 $form->{addition} = "SAVED";
1333 $form->save_history($form->dbconnect(\%myconfig));
1335 # /saving the history
1337 $lxdebug->leave_sub();
1340 sub save_and_close {
1341 $lxdebug->enter_sub();
1343 # $locale->text('Customer saved!')
1344 # $locale->text('Vendor saved!')
1346 $msg = ucfirst $form->{db};
1349 $form->isblank("name", $locale->text("Name missing!"));
1350 $rc = &{"CT::save_$form->{db}"}("", \%myconfig, \%$form);
1352 $form->error($locale->text('customernumber not unique!'));
1354 # saving the history
1355 if(!exists $form->{addition}) {
1356 $form->{addition} = "SAVED";
1357 $form->save_history($form->dbconnect(\%myconfig));
1359 # /saving the history
1360 $form->redirect($locale->text($msg));
1362 $lxdebug->leave_sub();
1366 $lxdebug->enter_sub();
1368 # $locale->text('Customer saved!')
1369 # $locale->text('Vendor saved!')
1371 $msg = ucfirst $form->{db};
1374 $form->isblank("name", $locale->text("Name missing!"));
1376 my $res = &{"CT::save_$form->{db}"}("", \%myconfig, \%$form);
1379 if ($form->{"db"} eq "customer") {
1380 $form->error($locale->text('This customer number is already in use.'));
1382 $form->error($locale->text('This vendor number is already in use.'));
1385 # saving the history
1386 if(!exists $form->{addition}) {
1387 $form->{addition} = "SAVED";
1388 $form->save_history($form->dbconnect(\%myconfig));
1390 # /saving the history
1393 $lxdebug->leave_sub();
1397 $lxdebug->enter_sub();
1399 # $locale->text('Customer deleted!')
1400 # $locale->text('Cannot delete customer!')
1401 # $locale->text('Vendor deleted!')
1402 # $locale->text('Cannot delete vendor!')
1404 CT->delete(\%myconfig, \%$form);
1406 $msg = ucfirst $form->{db};
1407 $msg .= " deleted!";
1408 # saving the history
1409 if(!exists $form->{addition}) {
1410 $form->{addition} = "DELETED";
1411 $form->save_history($form->dbconnect(\%myconfig));
1413 # /saving the history
1414 $form->redirect($locale->text($msg));
1416 $msg = "Cannot delete $form->{db}";
1417 $form->error($locale->text($msg));
1419 $lxdebug->leave_sub();
1423 $lxdebug->enter_sub();
1428 $lxdebug->leave_sub();
1432 $lxdebug->enter_sub();
1435 $lxdebug->leave_sub();
1439 $lxdebug->enter_sub();
1441 CT->get_contact(\%myconfig, \%$form);
1444 $result = "$form->{cp_name}";
1445 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);
1448 $lxdebug->leave_sub();
1453 $lxdebug->enter_sub();
1455 CT->get_shipto(\%myconfig, \%$form);
1458 $result = "$form->{shiptoname}";
1459 map { $result .= "__pjx__" . $form->{$_} } qw(shiptodepartment_1 shiptodepartment_2 shiptostreet shiptozipcode shiptocity shiptocountry shiptocontact shiptophone shiptofax shiptoemail);
1462 $lxdebug->leave_sub();
1467 $lxdebug->enter_sub();
1469 CT->get_delivery(\%myconfig, \%$form );
1472 $form->sort_columns(shiptoname,
1482 $column_header{shiptoname} =
1483 qq|<th class=listheading>| . $locale->text('Shipping Address') . qq|</th>|;
1484 $column_header{invnumber} =
1485 qq|<th class=listheading>|. $locale->text('Invoice'). qq|</th>|;
1486 $column_header{ordnumber} =
1487 qq|<th class=listheading>|. $locale->text('Order'). qq|</th>|;
1488 $column_header{transdate} =
1489 qq|<th class=listheading>| . $locale->text('Invdate') . qq|</th>|;
1490 $column_header{description} =
1491 qq|<th class=listheading>| . $locale->text('Description') . qq|</th>|;
1492 $column_header{qty} =
1493 qq|<th class=listheading>| . $locale->text('Qty') . qq|</th>|;
1494 $column_header{unit} =
1495 qq|<th class=listheading>| . $locale->text('Unit') . qq|</th>|;
1502 <tr class=listheading>
1505 map { $result .= "$column_header{$_}\n" } @column_index;
1512 foreach $ref (@{ $form->{DELIVERY} }) {
1514 if ($ref->{shiptoname} eq $sameshiptoname) {
1515 map { $column_data{$_} = "<td>$ref->{$_} </td>" } @column_index;
1516 $column_data{shiptoname} = "<td> </td>";
1518 map { $column_data{$_} = "<td>$ref->{$_} </td>" } @column_index;
1524 <tr class=listrow$i>
1527 map { $result .= "$column_data{$_}\n" } @column_index;
1533 $sameshiptoname = $ref->{shiptoname};
1545 $lxdebug->leave_sub();
1549 sub continue { &{ $form->{nextsub} } }