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>
115 <th align=right nowrap>| . $locale->text('Include in Report') . qq|</th>
119 <td><input name="l_id" type=checkbox class=checkbox value=Y> |
120 . $locale->text('ID') . qq|</td>
121 <td><input name="l_$form->{db}number" type=checkbox class=checkbox value=Y> |
122 . $locale->text($label . ' Number') . qq|</td>
123 <td><input name="l_name" type=checkbox class=checkbox value=Y checked> |
124 . $locale->text('Company Name') . qq|</td>
125 <td><input name="l_address" type=checkbox class=checkbox value=Y> |
126 . $locale->text('Address') . qq|</td>
129 <td><input name="l_contact" type=checkbox class=checkbox value=Y checked> |
130 . $locale->text('Contact') . qq|</td>
131 <td><input name="l_phone" type=checkbox class=checkbox value=Y checked> |
132 . $locale->text('Phone') . qq|</td>
133 <td><input name="l_fax" type=checkbox class=checkbox value=Y> |
134 . $locale->text('Fax') . qq|</td>
135 <td><input name="l_email" type=checkbox class=checkbox value=Y checked> |
136 . $locale->text('E-mail') . qq|</td>
139 <td><input name="l_taxnumber" type=checkbox class=checkbox value=Y> |
140 . $locale->text('Tax Number') . qq|</td>
141 <td><input name="l_sic_code" type=checkbox class=checkbox value=Y> |
142 . $locale->text('SIC') . qq|</td>
143 <td><input name="l_business" type=checkbox class=checkbox value=Y> |
144 . $locale->text('Type of Business') . qq|</td>
147 <td><input name="l_invnumber" type=checkbox class=checkbox value=Y> |
148 . $locale->text('Invoices') . qq|</td>
149 <td><input name="l_ordnumber" type=checkbox class=checkbox value=Y> |
150 . $locale->text('Orders') . qq|</td>
151 <td><input name="l_quonumber" type=checkbox class=checkbox value=Y> |
152 . $locale->text('Quotations') . qq|</td>
161 <td><hr size=3 noshade></td>
165 <input type=hidden name=nextsub value=list_names>
167 <input type=hidden name=path value=$form->{path}>
168 <input type=hidden name=login value=$form->{login}>
169 <input type=hidden name=password value=$form->{password}>
172 <input type=submit class=submit name=action value="|
173 . $locale->text('Continue') . qq|">
179 $lxdebug->leave_sub();
182 sub search_delivery {
183 $lxdebug->enter_sub();
185 $label = ucfirst $form->{db};
186 $form->{title} = $locale->text($label . "s");
193 <form method=post action=$form->{script}>
195 <input type=hidden name=db value=$form->{db}>
199 <th class=listtop>$form->{title}</th>
206 <th align=right nowrap>| . $locale->text($label . ' Number') . qq|</th>
207 <td><input name=$form->{db}number size=35></td>
210 <th align=right nowrap>| . $locale->text('Company Name') . qq|</th>
211 <td><input name=name size=35></td>
214 <th align=right nowrap>| . $locale->text('Contact') . qq|</th>
215 <td><input name=contact size=35></td>
218 <th align=right nowrap>| . $locale->text('E-mail') . qq|</th>
219 <td><input name=email size=35></td>
223 <td><input name=status class=radio type=radio value=all checked> |
224 . $locale->text('All') . qq|
225 <input name=status class=radio type=radio value=orphaned> |
226 . $locale->text('Orphaned') . qq|</td>
229 <th align=right nowrap>| . $locale->text('Include in Report') . qq|</th>
233 <td><input name="l_id" type=checkbox class=checkbox value=Y> |
234 . $locale->text('ID') . qq|</td>
235 <td><input name="l_$form->{db}number" type=checkbox class=checkbox value=Y> |
236 . $locale->text($label . ' Number') . qq|</td>
237 <td><input name="l_name" type=checkbox class=checkbox value=Y checked> |
238 . $locale->text('Company Name') . qq|</td>
239 <td><input name="l_address" type=checkbox class=checkbox value=Y> |
240 . $locale->text('Address') . qq|</td>
243 <td><input name="l_contact" type=checkbox class=checkbox value=Y checked> |
244 . $locale->text('Contact') . qq|</td>
245 <td><input name="l_phone" type=checkbox class=checkbox value=Y checked> |
246 . $locale->text('Phone') . qq|</td>
247 <td><input name="l_fax" type=checkbox class=checkbox value=Y> |
248 . $locale->text('Fax') . qq|</td>
249 <td><input name="l_email" type=checkbox class=checkbox value=Y checked> |
250 . $locale->text('E-mail') . qq|</td>
253 <td><input name="l_taxnumber" type=checkbox class=checkbox value=Y> |
254 . $locale->text('Tax Number') . qq|</td>
255 <td><input name="l_sic_code" type=checkbox class=checkbox value=Y> |
256 . $locale->text('SIC') . qq|</td>
257 <td><input name="l_business" type=checkbox class=checkbox value=Y> |
258 . $locale->text('Type of Business') . qq|</td>
261 <td><input name="l_invnumber" type=checkbox class=checkbox value=Y> |
262 . $locale->text('Invoices') . qq|</td>
263 <td><input name="l_ordnumber" type=checkbox class=checkbox value=Y> |
264 . $locale->text('Orders') . qq|</td>
265 <td><input name="l_quonumber" type=checkbox class=checkbox value=Y> |
266 . $locale->text('Quotations') . qq|</td>
275 <td><hr size=3 noshade></td>
279 <input type=hidden name=nextsub value=list_names>
281 <input type=hidden name=path value=$form->{path}>
282 <input type=hidden name=login value=$form->{login}>
283 <input type=hidden name=password value=$form->{password}>
286 <input type=submit class=submit name=action value="|
287 . $locale->text('Continue') . qq|">
293 $lxdebug->leave_sub();
297 $lxdebug->enter_sub();
299 CT->search(\%myconfig, \%$form);
302 "$form->{script}?action=list_names&db=$form->{db}&path=$form->{path}&login=$form->{login}&password=$form->{password}&status=$form->{status}";
306 $form->sort_columns(id, name,
307 "$form->{db}number", address,
312 invnumber, ordnumber,
315 foreach $item (@columns) {
316 if ($form->{"l_$item"} eq "Y") {
317 push @column_index, $item;
319 # add column to href and callback
320 $callback .= "&l_$item=Y";
321 $href .= "&l_$item=Y";
325 ($form->{db} eq "customer")
326 ? $locale->text('Customer Number')
327 : $locale->text('Vendor Number');
329 if ($form->{status} eq 'all') {
330 $option = $locale->text('All');
332 if ($form->{status} eq 'orphaned') {
333 $option .= $locale->text('Orphaned');
336 $callback .= "&name=" . $form->escape($form->{name}, 1);
337 $href .= "&name=" . $form->escape($form->{name});
338 $option .= "\n<br>" . $locale->text('Name') . " : $form->{name}";
340 if ($form->{contact}) {
341 $callback .= "&contact=" . $form->escape($form->{contact}, 1);
342 $href .= "&contact=" . $form->escape($form->{contact});
343 $option .= "\n<br>" . $locale->text('Contact') . " : $form->{contact}";
345 if ($form->{"$form->{db}number"}) {
347 qq|&$form->{db}number=| . $form->escape($form->{"$form->{db}number"}, 1);
349 "&$form->{db}number=" . $form->escape($form->{"$form->{db}number"});
351 "\n<br>" . $locale->text('Number') . qq| : $form->{"$form->{db}number"}|;
353 if ($form->{email}) {
354 $callback .= "&email=" . $form->escape($form->{email}, 1);
355 $href .= "&email=" . $form->escape($form->{email});
356 $option .= "\n<br>" . $locale->text('E-mail') . " : $form->{email}";
359 $form->{callback} = "$callback&sort=$form->{sort}";
360 $callback = $form->escape($form->{callback});
363 qq|<th class=listheading>| . $locale->text('ID') . qq|</th>|;
364 $column_header{"$form->{db}number"} =
365 qq|<th><a class=listheading href=$href&sort=$form->{db}number>$number</a></th>|;
366 $column_header{name} =
367 qq|<th><a class=listheading href=$href&sort=name>|
368 . $locale->text('Name')
370 $column_header{address} =
371 qq|<th><a class=listheading href=$href&sort=address>|
372 . $locale->text('Address')
374 $column_header{contact} =
375 qq|<th><a class=listheading href=$href&sort=contact>|
376 . $locale->text('Contact')
378 $column_header{phone} =
379 qq|<th><a class=listheading href=$href&sort=phone>|
380 . $locale->text('Phone')
382 $column_header{fax} =
383 qq|<th><a class=listheading href=$href&sort=fax>|
384 . $locale->text('Fax')
386 $column_header{email} =
387 qq|<th><a class=listheading href=$href&sort=email>|
388 . $locale->text('E-mail')
391 qq|<th><a class=listheading href=$href&sort=cc>|
392 . $locale->text('Cc')
395 $column_header{taxnumber} =
396 qq|<th><a class=listheading href=$href&sort=taxnumber>|
397 . $locale->text('Tax Number')
399 $column_header{sic_code} =
400 qq|<th><a class=listheading href=$href&sort=sic_code>|
401 . $locale->text('SIC')
403 $column_header{business} =
404 qq|<th><a class=listheading href=$href&sort=business>|
405 . $locale->text('Type of Business')
408 $column_header{invnumber} =
409 qq|<th><a class=listheading href=$href&sort=invnumber>|
410 . $locale->text('Invoice')
412 $column_header{ordnumber} =
413 qq|<th><a class=listheading href=$href&sort=ordnumber>|
414 . $locale->text('Order')
416 $column_header{quonumber} =
417 qq|<th><a class=listheading href=$href&sort=quonumber>|
418 . $locale->text('Quotation')
421 $label = ucfirst $form->{db} . "s";
422 $form->{title} = $locale->text($label);
431 <th class=listtop>$form->{title}</th>
440 <tr class=listheading>
443 map { print "$column_header{$_}\n" } @column_index;
449 $ordertype = ($form->{db} eq 'customer') ? 'sales_order' : 'purchase_order';
451 ($form->{db} eq 'customer') ? 'sales_quotation' : 'request_quotation';
453 foreach $ref (@{ $form->{CT} }) {
455 if ($ref->{id} eq $sameid) {
456 map { $column_data{$_} = "<td> </td>" } @column_index;
458 map { $column_data{$_} = "<td>$ref->{$_} </td>" } @column_index;
460 map { $column_data{$_} = "<td>$ref->{$_} </td>" }
461 (invnumber, ordnumber, quonumber);
464 "<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>";
467 $email = $ref->{email};
468 $email =~ s/</\</;
469 $email =~ s/>/\>/;
471 $column_data{email} =
472 qq|<td><a href="mailto:$ref->{email}">$email</a></td>|;
477 if ($ref->{formtype} eq 'invoice') {
478 $column_data{invnumber} =
479 "<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>";
482 if ($ref->{formtype} eq 'order') {
483 $column_data{ordnumber} =
484 "<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>";
487 if ($ref->{formtype} eq 'quotation') {
488 $column_data{quonumber} =
489 "<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>";
498 map { print "$column_data{$_}\n" } @column_index;
504 $sameid = $ref->{id};
513 <td><hr size=3 noshade></td>
518 <form method=post action=$form->{script}>
520 <input name=callback type=hidden value="$form->{callback}">
521 <input name=db type=hidden value=$form->{db}>
523 <input type=hidden name=path value=$form->{path}>
524 <input type=hidden name=login value=$form->{login}>
525 <input type=hidden name=password value=$form->{password}>
527 <input class=submit type=submit name=action value="|
528 . $locale->text('Add') . qq|">
536 $lxdebug->leave_sub();
540 $lxdebug->enter_sub();
542 # show history button
543 $form->{javascript} = qq|<script type=text/javascript src=js/show_history.js></script>|;
544 #/show hhistory button
546 # $locale->text('Edit Customer')
547 # $locale->text('Edit Vendor')
549 CT->get_tuple(\%myconfig, \%$form);
550 CT->populate_drop_down_boxes(\%myconfig, \%$form);
552 # format " into "
553 map { $form->{$_} =~ s/\"/"/g } keys %$form;
555 $form->{title} = "Edit";
558 $form->{discount} *= 100;
563 $lxdebug->leave_sub();
567 $lxdebug->enter_sub();
569 $form->get_lists("employees" => "ALL_SALESMEN");
571 $form->{taxincluded} = ($form->{taxincluded}) ? "checked" : "";
572 $form->{creditlimit} =
573 $form->format_amount(\%myconfig, $form->{creditlimit}, 0);
574 $form->{discount} = $form->format_amount(\%myconfig, $form->{discount});
576 if ($myconfig{role} eq 'admin') {
579 <th align=right nowrap>| . $locale->text('Bcc') . qq|</th>
580 <td><input name=bcc size=35 value="$form->{bcc}"></td>
584 $form->{obsolete} = "checked" if $form->{obsolete};
586 $lang = qq|<option value=""></option>|;
587 foreach $item (@{ $form->{languages} }) {
588 if ($form->{language_id} eq $item->{id}) {
589 $lang .= qq|<option value="$item->{id}" selected>$item->{description}</option>|;
591 $lang .= qq|<option value="$item->{id}">$item->{description}</option>|;
595 $payment = qq|<option value=""></option>|;
596 foreach $item (@{ $form->{payment_terms} }) {
597 if ($form->{payment_id} eq $item->{id}) {
598 $payment .= qq|<option value="$item->{id}" selected>$item->{description}</option>|;
600 $payment .= qq|<option value="$item->{id}">$item->{description}</option>|;
605 if ($form->{db} eq "customer") {
606 $form->{taxzone_id} = 0;
608 $form->{taxzone_id} = 0;
612 if (@{ $form->{TAXZONE} }) {
613 foreach $item (@{ $form->{TAXZONE} }) {
614 if ($item->{id} == $form->{taxzone_id}) {
615 $form->{selecttaxzone} .=
616 "<option value=$item->{id} selected>$item->{description}\n";
618 $form->{selecttaxzone} .=
619 "<option value=$item->{id}>$item->{description}\n";
626 <th align=right>| . $locale->text('Steuersatz') . qq|</th>
627 <td><select name=taxzone_id>$form->{selecttaxzone}</select></td>
628 <input type=hidden name=selecttaxzone value="$form->{selecttaxzone}">
632 "$form->{script}?login=$form->{login}&path=$form->{path}&password=$form->{password}&action=get_contact";
634 my $pjx = new CGI::Ajax( 'get_contact' => $get_contact_url );
635 $form->{selectcontact} = "<option value=0></option>";
636 if (@{ $form->{CONTACTS} }) {
637 foreach $item (@{ $form->{CONTACTS} }) {
638 if ($item->{cp_id} == $form->{cp_id}) {
639 $form->{selectcontact} .=
640 qq|<option value=$item->{cp_id} selected>$item->{cp_name}</option>\n|;
642 $form->{selectcontact} .=
643 qq|<option value=$item->{cp_id}>$item->{cp_name}</option>\n|;
648 push(@ { $form->{AJAX} }, $pjx);
649 $ansprechpartner = qq|
651 <th align=right>| . $locale->text('Ansprechpartner') . qq|</th>
652 <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>
653 <input type=hidden name=selectcontact value="$form->{selectcontact}">
656 "$form->{script}?login=$form->{login}&path=$form->{path}&password=$form->{password}&action=get_shipto";
658 my $pjy = new CGI::Ajax( 'get_shipto' => $get_shipto_url );
659 $form->{selectshipto} = "<option value=0></option>";
660 $form->{selectshipto} .= "<option value=0>Alle</option>";
661 if (@{ $form->{SHIPTO} }) {
662 foreach $item (@{ $form->{SHIPTO} }) {
663 if ($item->{shipto_id} == $form->{shipto_id}) {
664 $form->{selectshipto} .=
665 "<option value=$item->{shipto_id} selected>$item->{shiptoname} $item->{shiptodepartment_1}\n";
667 $form->{selectshipto} .=
668 "<option value=$item->{shipto_id}>$item->{shiptoname} $item->{shiptodepartment_1}\n";
673 push(@ { $form->{AJAX} }, $pjy);
677 <th align=right>| . $locale->text('Shipping Address') . qq|</th>
678 <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>
679 <input type=hidden name=selectshipto value="$form->{selectshipto}">
684 "$form->{script}?login=$form->{login}&path=$form->{path}&password=$form->{password}&action=get_delivery";
686 my $pjz = new CGI::Ajax( 'get_delivery' => $get_delivery_url );
688 push(@ { $form->{AJAX} }, $pjz);
692 <th align=right>| . $locale->text('Shipping Address') . qq|</th>
693 <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>
696 $form->{selectbusiness} = qq|<option>\n|;
698 $form->{selectbusiness} .=
699 qq|<option value=$_->{id}>$_->{description}\n|
700 } @{ $form->{all_business} };
701 if ($form->{business_save}) {
702 $form->{selectbusiness} = $form->{business_save};
704 $form->{selectbusiness} =~
705 s/<option value=$form->{business}>/<option value=$form->{business} selected>/;
707 $label = ucfirst $form->{db};
708 if ($form->{title} eq "Edit") {
709 $form->{title} = $locale->text("$form->{title} $label") . " $form->{name}";
711 $form->{title} = $locale->text("$form->{title} $label");
713 if ($form->{title_save}) {
714 $form->{title} = $form->{title_save};
716 if ($form->{db} eq 'vendor') {
718 <th align=right>| . $locale->text('Kundennummer') . qq|</th>
719 <td><input name=v_customer_id size=10 maxlength=35 value="$form->{v_customer_id}"></td>
723 if ($form->{db} eq 'customer') {
726 <th align=right>| . $locale->text('KNr. beim Kunden') . qq|</th>
727 <td><input name=c_vendor_id size=10 maxlength=35 value="$form->{c_vendor_id}"></td>
732 <th align=right>| . $locale->text('Type of Business') . qq|</th>
733 <td><select name=business>$form->{selectbusiness}</select></td>
738 if ($form->{db} eq "customer") {
739 my (@salesman_values, %salesman_labels);
740 push(@salesman_values, undef);
741 foreach my $item (@{ $form->{ALL_SALESMEN} }) {
742 push(@salesman_values, $item->{id});
743 $salesman_labels{$item->{id}} = $item->{name} ne "" ? $item->{name} : $item->{login};
747 qq| <th align="right">| . $locale->text('Salesman') . qq|</th>
749 NTI($cgi->popup_menu('-name' => 'salesman_id', '-default' => $form->{salesman_id},
750 '-values' => \@salesman_values, '-labels' => \%salesman_labels))
754 ## LINET: Create a drop-down box with all prior titles and greetings.
755 CT->query_titles_and_greetings(\%myconfig, \%$form);
757 $select_title = qq| <select name=selected_cp_title><option></option>|;
758 map({ $select_title .= qq|<option>$_</option>|; } @{ $form->{TITLES} });
759 $select_title .= qq|</select>|;
762 qq| <select name=selected_cp_greeting><option></option>|;
764 { $select_greeting .= qq|<option>$_</option>|; } @{ $form->{GREETINGS} });
765 $select_greeting .= qq|</select>|;
767 $select_company_greeting =
768 qq| <select name=selected_company_greeting><option></option>|;
770 { $select_company_greeting .= qq|<option>$_</option>|; } @{ $form->{COMPANY_GREETINGS} });
771 $select_company_greeting .= qq|</select>|;
774 qq| <select name=selected_cp_abteilung><option></option>|;
776 { $select_department .= qq|<option>$_</option>|; } @{ $form->{DEPARTMENT} });
777 $select_department .= qq|</select>|;
780 if ($form->{db} eq 'customer') {
782 #get pricegroup and form it
783 $form->get_pricegroup(\%myconfig, { all => 1 });
785 $form->{pricegroup} = "$form->{klass}";
786 $form->{pricegroup_id} = "$form->{klass}";
788 if (@{ $form->{all_pricegroup} }) {
790 $form->{selectpricegroup} = qq|<option>\n|;
792 $form->{selectpricegroup} .=
793 qq|<option value="$_->{id}">$_->{pricegroup}\n|
794 } @{ $form->{all_pricegroup} };
797 if ($form->{selectpricegroup}) {
798 $form->{selectpricegroup} = $form->unescape($form->{selectpricegroup});
801 qq|<input type=hidden name=selectpricegroup value="|
802 . $form->escape($form->{selectpricegroup}, 1) . qq|">|;
804 $form->{selectpricegroup} =~
805 s/(<option value="\Q$form->{klass}\E")/$1 selected/;
808 qq|<select name=klass>$form->{selectpricegroup}</select>|;
813 # $locale->text('Customer Number')
814 # $locale->text('Vendor Number')
815 $form->{fokus} = "ct.greeting";
816 $form->{jsscript} = 1;
820 <body onLoad="fokus()">
823 <th class=listtop>$form->{title}</th>
828 <form method=post name="ct" action=$form->{script} onKeyUp="highlight(event)" onClick="highlight(event)">
832 <ul id="maintab" class="shadetabs">
833 <li class="selected"><a href="#" rel="billing">|
834 . $locale->text('Billing Address') . qq|</a></li>
835 <li><a href="#" rel="shipto">|
836 . $locale->text('Shipping Address') . qq|</a></li>
837 <li><a href="#" rel="contacts">Ansprechpartner</a></li>
838 <li><a href="#" rel="deliveries">|
839 . $locale->text('Lieferungen') . qq|</a></li>
843 <div class="tabcontentstyle">
845 <div id="billing" class="tabcontent">
850 <th align=right nowrap>| . $locale->text($label . ' Number') . qq|</th>
851 <td><input name="$form->{db}number" size=35 maxlength=35 value="$form->{"$form->{db}number"}"></td>
854 <th align=right nowrap>| . $locale->text('Greeting') . qq|</th>
855 <td><input id=greeting name=greeting size=30 maxlength=30 value="$form->{greeting}">
856 $select_company_greeting</td>
859 <th align=right nowrap>| . $locale->text('Company Name') . qq|</th>
860 <td><input name=name size=35 maxlength=75 value="$form->{name}"></td>
863 <th align=right nowrap>| . $locale->text('Abteilung') . qq|</th>
864 <td><input name=department_1 size=16 maxlength=75 value="$form->{department_1}">
865 <input name=department_2 size=16 maxlength=75 value="$form->{department_2}"></td>
868 <th align=right nowrap>| . $locale->text('Street') . qq|</th>
869 <td><input name=street size=35 maxlength=75 value="$form->{street}"></td>
872 <th align=right nowrap>|
873 . $locale->text('Zipcode') . "/" . $locale->text('City') . qq|</th>
874 <td><input name=zipcode size=5 maxlength=10 value="$form->{zipcode}">
875 <input name=city size=30 maxlength=75 value="$form->{city}"></td>
878 <th align=right nowrap>| . $locale->text('Country') . qq|</th>
879 <td><input name=country size=35 maxlength=75 value="$form->{country}"></td>
882 <th align=right nowrap>| . $locale->text('Contact') . qq|</th>
883 <td><input name=contact size=28 maxlength=75 value="$form->{contact}"></td>
886 <th align=right nowrap>| . $locale->text('Phone') . qq|</th>
887 <td><input name=phone size=30 maxlength=30 value="$form->{phone}"></td>
890 <th align=right nowrap>| . $locale->text('Fax') . qq|</th>
891 <td><input name=fax size=30 maxlength=30 value="$form->{fax}"></td>
894 <th align=right nowrap>| . $locale->text('E-mail') . qq|</th>
895 <td><input name=email size=45 value="$form->{email}"></td>
898 <th align=right nowrap>| . $locale->text('Homepage') . qq|</th>
899 <td><input name=homepage size=45 value="$form->{homepage}"></td>
904 <th align=right>| . $locale->text('Credit Limit') . qq|</th>
905 <td><input name=creditlimit size=9 value="$form->{creditlimit}"></td>
906 <input type="hidden" name="terms" value="$form->{terms}">
907 <th align=right>| . $locale->text('Payment Terms') . qq|</th>
908 <td><select name=payment_id>$payment</select></td>
909 <th align=right>| . $locale->text('Discount') . qq|</th>
910 <td><input name=discount size=4 value="$form->{discount}">
914 <th align=right>| . $locale->text('Tax Number / SSN') . qq|</th>
915 <td><input name=taxnumber size=20 value="$form->{taxnumber}"></td>
916 <th align=right>| . $locale->text('USt-IdNr.') . qq|</th>
917 <td><input name="ustid" maxlength="14" size="20" value="$form->{ustid}"></td>
921 <th align=right>| . $locale->text('Account Number') . qq|</th>
922 <td><input name=account_number size=10 value="$form->{account_number}"></td>
923 <th align=right>| . $locale->text('Bank Code Number') . qq|</th>
924 <td><input name=bank_code size=10 value="$form->{bank_code}"></td>
925 <th align=right>| . $locale->text('Bank') . qq|</th>
926 <td><input name=bank size=30 value="$form->{bank}"></td>
930 <th align=right>| . $locale->text('Language') . qq|</th>
931 <td><select name=language_id>$lang
934 if ($form->{db} eq 'customer') {
937 <th align=right>| . $locale->text('Preisklasse') . qq|</th>
938 <td>$pricegroup</td>|;
942 <td align=right>| . $locale->text('Obsolete') . qq|</td>
943 <td><input name=obsolete class=checkbox type=checkbox value=1 $form->{obsolete}></td>
952 <th align=left nowrap>| . $locale->text('Notes') . qq|</th>
955 <td><textarea name=notes rows=3 cols=60 wrap=soft>$form->{notes}</textarea></td>
962 <br style="clear: left" /></div>|;
965 <div id="shipto" class="tabcontent">
970 <th align=right nowrap>| . $locale->text('Company Name') . qq|</th>
971 <td><input id=shiptoname name=shiptoname size=35 maxlength=75 value="$form->{shiptoname}"></td>
974 <th align=right nowrap>| . $locale->text('Abteilung') . qq|</th>
975 <td><input id=shiptodepartment_1 name=shiptodepartment_1 size=16 maxlength=75 value="$form->{shiptodepartment_1}">
976 <input id=shiptodepartment_2 name=shiptodepartment_2 size=16 maxlength=75 value="$form->{shiptodepartment_2}"></td>
979 <th align=right nowrap>| . $locale->text('Street') . qq|</th>
980 <td><input id=shiptostreet name=shiptostreet size=35 maxlength=75 value="$form->{shiptostreet}"></td>
983 <th align=right nowrap>|
984 . $locale->text('Zipcode') . "/" . $locale->text('City') . qq|</th>
985 <td><input id=shiptozipcode name=shiptozipcode size=5 maxlength=10 value="$form->{shiptozipcode}">
986 <input id=shiptocity name=shiptocity size=30 maxlength=75 value="$form->{shiptocity}"></td>
989 <th align=right nowrap>| . $locale->text('Country') . qq|</th>
990 <td><input id=shiptocountry name=shiptocountry size=35 maxlength=35 value="$form->{shiptocountry}"></td>
993 <th align=right nowrap>| . $locale->text('Contact') . qq|</th>
994 <td><input id=shiptocontact name=shiptocontact size=30 maxlength=75 value="$form->{shiptocontact}"></td>
997 <th align=right nowrap>| . $locale->text('Phone') . qq|</th>
998 <td><input id=shiptophone name=shiptophone size=30 maxlength=30 value="$form->{shiptophone}"></td>
1001 <th align=right nowrap>| . $locale->text('Fax') . qq|</th>
1002 <td><input id=shiptofax name=shiptofax size=30 maxlength=30 value="$form->{shiptofax}"></td>
1005 <th align=right nowrap>| . $locale->text('E-mail') . qq|</th>
1006 <td><input id=shiptoemail name=shiptoemail size=45 value="$form->{shiptoemail}"></td>
1016 <br style="clear: left" /></div>|;
1019 ##LINET - added fields for contact person
1021 <div id="contacts" class="tabcontent">
1025 <input type=hidden name=cp_id value=$form->{cp_id}>
1029 <th align=left nowrap>| . $locale->text('Greeting') . qq|</th>
1030 <td><input id=cp_greeting name=cp_greeting size=30 maxlength=30 value="$form->{cp_greeting}">
1031 $select_greeting</td>
1034 <th align=left nowrap>| . $locale->text('Title') . qq|</th>
1035 <td><input id=cp_title name=cp_title size=30 maxlength=30 value="$form->{cp_title}">
1039 <th align=left nowrap>| . $locale->text('Department') . qq|</th>
1040 <td><input id=cp_abteilung name=cp_abteilung size=30 maxlength=40 value="$form->{cp_abteilung}">
1041 $select_department</td>
1044 <th align=left nowrap>|
1045 . $locale->text('Given Name') . qq|</th>
1046 <td><input id=cp_givenname name=cp_givenname size=30 maxlength=40 value="$form->{cp_givenname}"></td>
1049 <th align=left nowrap>| . $locale->text('Name') . qq|</th>
1050 <td><input id=cp_name name=cp_name size=30 maxlength=40 value="$form->{cp_name}"></td>
1053 <th align=left nowrap>| . $locale->text('Phone1') . qq|</th>
1054 <td><input id=cp_phone1 name=cp_phone1 size=30 maxlength=30 value="$form->{cp_phone1}"></td>
1057 <th align=left nowrap>| . $locale->text('Phone2') . qq|</th>
1058 <td><input id=cp_phone2 name=cp_phone2 size=30 maxlength=30 value="$form->{cp_phone2}"></td>
1061 <th align=left nowrap>| . $locale->text('Fax') . qq|</th>
1062 <td><input id=cp_fax name=cp_fax size=30 maxlength=30 value="$form->{cp_fax}"></td>
1065 <th align=left nowrap>| . $locale->text('Mobile1') . qq|</th>
1066 <td><input id=cp_mobile1 name=cp_mobile1 size=30 maxlength=30 value="$form->{cp_mobile1}"></td>
1069 <th align=left nowrap>| . $locale->text('Mobile2') . qq|</th>
1070 <td><input id=cp_mobile2 name=cp_mobile2 size=30 maxlength=30 value="$form->{cp_mobile2}"></td>
1073 <th align=left nowrap>| . $locale->text('Sat. Phone') . qq|</th>
1074 <td><input id=cp_satphone name=cp_satphone size=30 maxlength=30 value="$form->{cp_satphone}"></td>
1077 <th align=left nowrap>| . $locale->text('Sat. Fax') . qq|</th>
1078 <td><input id=cp_satfax name=cp_satfax size=30 maxlength=30 value="$form->{cp_satfax}"></td>
1081 <th align=left nowrap>| . $locale->text('Project') . qq|</th>
1082 <td><input id=cp_project name=cp_project size=30 maxlength=40 value="$form->{cp_project}"></td>
1085 <th align=left nowrap>| . $locale->text('E-mail') . qq|</th>
1086 <td><input id=cp_email name=cp_email size=30 maxlength=40 value="$form->{cp_email}"></td>
1089 <th align=left nowrap>| . $locale->text('Private Phone') . qq|</th>
1090 <td><input id=cp_privatphone name=cp_privatphone size=30 maxlength=40 value="$form->{cp_privatphone}"></td>
1093 <th align=left nowrap>| . $locale->text('Private E-mail') . qq|</th>
1094 <td><input id=cp_privatemail name=cp_privatemail size=30 maxlength=40 value="$form->{cp_privatemail}"></td>
1097 <th align=left nowrap>| . $locale->text('Birthday') . qq|</th>
1098 <td><input id=cp_birthday name=cp_birthday size=30 maxlength=40 value="$form->{cp_birthday}"></td>
1104 <tr height="5"></tr>|;
1114 <br style="clear: left" /></div>
1115 <div id="deliveries" class="tabcontent">
1119 <th align=left nowrap>| . $locale->text('From') . qq|</th>
1120 <td><input id=from name=from size=10 maxlength=10 value="$form->{from}">
1121 <input type="button" name="fromB" id="trigger_from" value="?"></td>
1122 <th align=left nowrap>| . $locale->text('To (time)') . qq|</th>
1123 <td><input id=to name=to size=10 maxlength=10 value="$form->{to}">
1124 <input type="button" name="toB" id="trigger_to" value="?"></td>
1133 <br style="clear: left" /></div>
1137 | . $form->write_trigger(\%myconfig, 2, "fromB", "BL", "trigger_from",
1138 "toB", "BL", "trigger_to");
1140 $lxdebug->leave_sub();
1144 $lxdebug->enter_sub();
1146 $label = ucfirst $form->{db};
1148 ($form->{db} eq 'customer')
1149 ? $locale->text('Save and Quotation')
1150 : $locale->text('Save and RFQ');
1152 ($form->{db} eq 'customer')
1153 ? $locale->text('Save and AR Transaction')
1154 : $locale->text('Save and AP Transaction');
1156 ##<input class=submit type=submit name=action value="|.$locale->text("Save and Quotation").qq|">
1157 ##<input class=submit type=submit name=action value="|.$locale->text("Save and RFQ").qq|">
1158 ##<input class=submit type=submit name=action value="|.$locale->text("Save and AR Transaction").qq|">
1159 ##<input class=submit type=submit name=action value="|.$locale->text("Save and AP Transaction").qq|">
1162 <input name=id type=hidden id=cvid value=$form->{id}>
1163 <input name=business_save type=hidden value="$form->{selectbusiness}">
1164 <input name=title_save type=hidden value="$form->{title}">
1166 <input type=hidden name=path value=$form->{path}>
1167 <input type=hidden name=login value=$form->{login}>
1168 <input type=hidden name=password value=$form->{password}>
1170 <input type=hidden name=callback value="$form->{callback}">
1171 <input type=hidden name=db id=db value=$form->{db}>
1176 <input class=submit type=submit name=action accesskey="s" value="|
1177 . $locale->text("Save") . qq|">
1178 <input class=submit type=submit name=action accesskey="s" value="|
1179 . $locale->text("Save and Close") . qq|">
1180 <input class=submit type=submit name=action value="$arap">
1181 <input class=submit type=submit name=action value="|
1182 . $locale->text("Save and Invoice") . qq|">
1183 <input class=submit type=submit name=action value="|
1184 . $locale->text("Save and Order") . qq|">
1185 <input class=submit type=submit name=action value="$quotation">
1188 if ($form->{id} && $form->{status} eq 'orphaned') {
1189 print qq|<input class=submit type=submit name=action value="|
1190 . $locale->text('Delete')
1194 # button for saving history
1195 if($form->{id} ne "") {
1197 <input type=button class=submit onclick=set_history_window(|
1199 . qq|); name=history id=history value=|
1200 . $locale->text('history')
1203 # /button for saving history
1208 <script type="text/javascript">
1209 //Start Tab Content script for UL with id="maintab" Separate multiple ids each with a comma.
1210 initializetabcontent("maintab")
1216 $lxdebug->leave_sub();
1219 sub add_transaction {
1220 $lxdebug->enter_sub();
1222 # # saving the history
1223 # if(!exists $form->{addition}) {
1224 # $form->{addition} = "ADD TRANSACTION";
1225 # $form->save_history($form->dbconnect(\%myconfig));
1227 # # /saving the history
1229 $form->isblank("name", $locale->text("Name missing!"));
1230 &{"CT::save_$form->{db}"}("", \%myconfig, \%$form);
1232 $form->{callback} = $form->escape($form->{callback}, 1);
1233 $name = $form->escape("$form->{name}", 1);
1236 "$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}";
1239 $lxdebug->leave_sub();
1242 sub save_and_ap_transaction {
1243 $lxdebug->enter_sub();
1245 $form->{script} = "ap.pl";
1246 # saving the history
1247 if(!exists $form->{addition}) {
1248 $form->{addition} = "SAVED";
1249 $form->save_history($form->dbconnect(\%myconfig));
1251 # /saving the history
1253 $lxdebug->leave_sub();
1256 sub save_and_ar_transaction {
1257 $lxdebug->enter_sub();
1259 $form->{script} = "ar.pl";
1260 # saving the history
1261 if(!exists $form->{addition}) {
1262 $form->{addition} = "SAVED";
1263 $form->save_history($form->dbconnect(\%myconfig));
1265 # /saving the history
1267 $lxdebug->leave_sub();
1270 sub save_and_invoice {
1271 $lxdebug->enter_sub();
1273 $form->{script} = ($form->{db} eq 'customer') ? "is.pl" : "ir.pl";
1274 $form->{type} = "invoice";
1275 # saving the history
1276 if(!exists $form->{addition}) {
1277 $form->{addition} = "SAVED";
1278 $form->save_history($form->dbconnect(\%myconfig));
1280 # /saving the history
1282 $lxdebug->leave_sub();
1286 $lxdebug->enter_sub();
1288 $form->{script} = "oe.pl";
1289 $form->{type} = "request_quotation";
1290 # saving the history
1291 if(!exists $form->{addition}) {
1292 $form->{addition} = "SAVED";
1293 $form->save_history($form->dbconnect(\%myconfig));
1295 # /saving the history
1297 $lxdebug->leave_sub();
1300 sub save_and_quotation {
1301 $lxdebug->enter_sub();
1303 $form->{script} = "oe.pl";
1304 $form->{type} = "sales_quotation";
1305 # saving the history
1306 if(!exists $form->{addition}) {
1307 $form->{addition} = "SAVED";
1308 $form->save_history($form->dbconnect(\%myconfig));
1310 # /saving the history
1312 $lxdebug->leave_sub();
1315 sub save_and_order {
1316 $lxdebug->enter_sub();
1318 $form->{script} = "oe.pl";
1320 ($form->{db} eq 'customer') ? "sales_order" : "purchase_order";
1321 # saving the history
1322 if(!exists $form->{addition}) {
1323 $form->{addition} = "SAVED";
1324 $form->save_history($form->dbconnect(\%myconfig));
1326 # /saving the history
1328 $lxdebug->leave_sub();
1331 sub save_and_close {
1332 $lxdebug->enter_sub();
1334 # $locale->text('Customer saved!')
1335 # $locale->text('Vendor saved!')
1337 $msg = ucfirst $form->{db};
1340 $form->isblank("name", $locale->text("Name missing!"));
1341 $rc = &{"CT::save_$form->{db}"}("", \%myconfig, \%$form);
1343 $form->error($locale->text('customernumber not unique!'));
1345 # saving the history
1346 if(!exists $form->{addition}) {
1347 $form->{addition} = "SAVED";
1348 $form->save_history($form->dbconnect(\%myconfig));
1350 # /saving the history
1351 $form->redirect($locale->text($msg));
1353 $lxdebug->leave_sub();
1357 $lxdebug->enter_sub();
1359 # $locale->text('Customer saved!')
1360 # $locale->text('Vendor saved!')
1362 $msg = ucfirst $form->{db};
1365 $form->isblank("name", $locale->text("Name missing!"));
1367 my $res = &{"CT::save_$form->{db}"}("", \%myconfig, \%$form);
1370 if ($form->{"db"} eq "customer") {
1371 $form->error($locale->text('This customer number is already in use.'));
1373 $form->error($locale->text('This vendor number is already in use.'));
1376 # saving the history
1377 if(!exists $form->{addition}) {
1378 $form->{addition} = "SAVED";
1379 $form->save_history($form->dbconnect(\%myconfig));
1381 # /saving the history
1384 $lxdebug->leave_sub();
1388 $lxdebug->enter_sub();
1390 # $locale->text('Customer deleted!')
1391 # $locale->text('Cannot delete customer!')
1392 # $locale->text('Vendor deleted!')
1393 # $locale->text('Cannot delete vendor!')
1395 CT->delete(\%myconfig, \%$form);
1397 $msg = ucfirst $form->{db};
1398 $msg .= " deleted!";
1399 # saving the history
1400 if(!exists $form->{addition}) {
1401 $form->{addition} = "DELETED";
1402 $form->save_history($form->dbconnect(\%myconfig));
1404 # /saving the history
1405 $form->redirect($locale->text($msg));
1407 $msg = "Cannot delete $form->{db}";
1408 $form->error($locale->text($msg));
1410 $lxdebug->leave_sub();
1414 $lxdebug->enter_sub();
1419 $lxdebug->leave_sub();
1423 $lxdebug->enter_sub();
1426 $lxdebug->leave_sub();
1430 $lxdebug->enter_sub();
1432 CT->get_contact(\%myconfig, \%$form);
1435 $result = "$form->{cp_name}";
1436 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);
1439 $lxdebug->leave_sub();
1444 $lxdebug->enter_sub();
1446 CT->get_shipto(\%myconfig, \%$form);
1449 $result = "$form->{shiptoname}";
1450 map { $result .= "__pjx__" . $form->{$_} } qw(shiptodepartment_1 shiptodepartment_2 shiptostreet shiptozipcode shiptocity shiptocountry shiptocontact shiptophone shiptofax shiptoemail);
1453 $lxdebug->leave_sub();
1458 $lxdebug->enter_sub();
1460 CT->get_delivery(\%myconfig, \%$form );
1463 $form->sort_columns(shiptoname,
1473 $column_header{shiptoname} =
1474 qq|<th class=listheading>| . $locale->text('Shipping Address') . qq|</th>|;
1475 $column_header{invnumber} =
1476 qq|<th class=listheading>|. $locale->text('Invoice'). qq|</th>|;
1477 $column_header{ordnumber} =
1478 qq|<th class=listheading>|. $locale->text('Order'). qq|</th>|;
1479 $column_header{transdate} =
1480 qq|<th class=listheading>| . $locale->text('Invdate') . qq|</th>|;
1481 $column_header{description} =
1482 qq|<th class=listheading>| . $locale->text('Description') . qq|</th>|;
1483 $column_header{qty} =
1484 qq|<th class=listheading>| . $locale->text('Qty') . qq|</th>|;
1485 $column_header{unit} =
1486 qq|<th class=listheading>| . $locale->text('Unit') . qq|</th>|;
1493 <tr class=listheading>
1496 map { $result .= "$column_header{$_}\n" } @column_index;
1503 foreach $ref (@{ $form->{DELIVERY} }) {
1505 if ($ref->{shiptoname} eq $sameshiptoname) {
1506 map { $column_data{$_} = "<td>$ref->{$_} </td>" } @column_index;
1507 $column_data{shiptoname} = "<td> </td>";
1509 map { $column_data{$_} = "<td>$ref->{$_} </td>" } @column_index;
1515 <tr class=listrow$i>
1518 map { $result .= "$column_data{$_}\n" } @column_index;
1524 $sameshiptoname = $ref->{shiptoname};
1536 $lxdebug->leave_sub();
1540 sub continue { &{ $form->{nextsub} } }