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}&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 my $vc_business_type = $form->{db} eq "customer" ?
72 $locale->text("Customer type") : $locale->text("Vendor type");
74 $form->get_lists("business_types" => "ALL_BUSINESS_TYPES");
75 my (%labels, @values);
78 if (scalar(@{ $form->{ALL_BUSINESS_TYPES} }) != 0) {
80 foreach my $item (@{ $form->{ALL_BUSINESS_TYPES} }) {
81 push(@values, $item->{id});
82 $labels{$item->{id}} = $item->{description};
87 <th align="right" nowrap>${vc_business_type}</th>
89 . NTI($cgi->popup_menu('-name' => 'business_id', '-values' => \@values,
90 '-labels' => \%labels))
96 $label = ucfirst $form->{db};
97 $form->{title} = $locale->text($label . "s");
104 <form method=post action=$form->{script}>
106 <input type=hidden name=db value=$form->{db}>
110 <th class=listtop>$form->{title}</th>
117 <th align=right nowrap>| . $locale->text($label . ' Number') . qq|</th>
118 <td><input name=$form->{db}number size=35></td>
121 <th align=right nowrap>| . $locale->text('Company Name') . qq|</th>
122 <td><input name=name size=35></td>
125 <th align=right nowrap>| . $locale->text('Contact') . qq|</th>
126 <td><input name=contact size=35></td>
129 <th align=right nowrap>| . $locale->text('E-mail') . qq|</th>
130 <td><input name=email size=35></td>
135 <td><input name=status class=radio type=radio value=all checked> |
136 . $locale->text('All') . qq|
137 <input name=status class=radio type=radio value=orphaned> |
138 . $locale->text('Orphaned') . qq|</td>
142 <td><input name="obsolete" class="radio" type="radio" value="all"> |
143 . $locale->text('All') . qq|
144 <input name="obsolete" class="radio" type="radio" value="Y"> |
145 . $locale->text('Obsolete') . qq|
146 <input name="obsolete" class="radio" type="radio" value="N" checked> |
147 . $locale->text('Not obsolete') . qq|</td>
150 <th align=right nowrap>| . $locale->text('Include in Report') . qq|</th>
154 <td><input name="l_id" type=checkbox class=checkbox value=Y> |
155 . $locale->text('ID') . qq|</td>
156 <td><input name="l_$form->{db}number" type=checkbox class=checkbox value=Y> |
157 . $locale->text($label . ' Number') . qq|</td>
158 <td><input name="l_name" type=checkbox class=checkbox value=Y checked> |
159 . $locale->text('Company Name') . qq|</td>
160 <td><input name="l_address" type=checkbox class=checkbox value=Y> |
161 . $locale->text('Address') . qq|</td>
164 <td><input name="l_contact" type=checkbox class=checkbox value=Y checked> |
165 . $locale->text('Contact') . qq|</td>
166 <td><input name="l_phone" type=checkbox class=checkbox value=Y checked> |
167 . $locale->text('Phone') . qq|</td>
168 <td><input name="l_fax" type=checkbox class=checkbox value=Y> |
169 . $locale->text('Fax') . qq|</td>
170 <td><input name="l_email" type=checkbox class=checkbox value=Y checked> |
171 . $locale->text('E-mail') . qq|</td>
174 <td><input name="l_taxnumber" type=checkbox class=checkbox value=Y> |
175 . $locale->text('Tax Number') . qq|</td>
176 <td><input name="l_sic_code" type=checkbox class=checkbox value=Y> |
177 . $locale->text('SIC') . qq|</td>
178 <td><input name="l_business" type=checkbox class=checkbox value=Y> |
179 . $vc_business_type . qq|</td>
182 <td><input name="l_invnumber" type=checkbox class=checkbox value=Y> |
183 . $locale->text('Invoices') . qq|</td>
184 <td><input name="l_ordnumber" type=checkbox class=checkbox value=Y> |
185 . $locale->text('Orders') . qq|</td>
186 <td><input name="l_quonumber" type=checkbox class=checkbox value=Y> |
187 . $locale->text('Quotations') . qq|</td>
196 <td><hr size=3 noshade></td>
200 <input type=hidden name=nextsub value=list_names>
202 <input type=hidden name=login value=$form->{login}>
203 <input type=hidden name=password value=$form->{password}>
206 <input type=submit class=submit name=action value="|
207 . $locale->text('Continue') . qq|">
213 $lxdebug->leave_sub();
216 sub search_delivery {
217 $lxdebug->enter_sub();
219 $label = ucfirst $form->{db};
220 $form->{title} = $locale->text($label . "s");
227 <form method=post action=$form->{script}>
229 <input type=hidden name=db value=$form->{db}>
233 <th class=listtop>$form->{title}</th>
240 <th align=right nowrap>| . $locale->text($label . ' Number') . qq|</th>
241 <td><input name=$form->{db}number size=35></td>
244 <th align=right nowrap>| . $locale->text('Company Name') . qq|</th>
245 <td><input name=name size=35></td>
248 <th align=right nowrap>| . $locale->text('Contact') . qq|</th>
249 <td><input name=contact size=35></td>
252 <th align=right nowrap>| . $locale->text('E-mail') . qq|</th>
253 <td><input name=email size=35></td>
257 <td><input name=status class=radio type=radio value=all checked> |
258 . $locale->text('All') . qq|
259 <input name=status class=radio type=radio value=orphaned> |
260 . $locale->text('Orphaned') . qq|</td>
263 <th align=right nowrap>| . $locale->text('Include in Report') . qq|</th>
267 <td><input name="l_id" type=checkbox class=checkbox value=Y> |
268 . $locale->text('ID') . qq|</td>
269 <td><input name="l_$form->{db}number" type=checkbox class=checkbox value=Y> |
270 . $locale->text($label . ' Number') . qq|</td>
271 <td><input name="l_name" type=checkbox class=checkbox value=Y checked> |
272 . $locale->text('Company Name') . qq|</td>
273 <td><input name="l_address" type=checkbox class=checkbox value=Y> |
274 . $locale->text('Address') . qq|</td>
277 <td><input name="l_contact" type=checkbox class=checkbox value=Y checked> |
278 . $locale->text('Contact') . qq|</td>
279 <td><input name="l_phone" type=checkbox class=checkbox value=Y checked> |
280 . $locale->text('Phone') . qq|</td>
281 <td><input name="l_fax" type=checkbox class=checkbox value=Y> |
282 . $locale->text('Fax') . qq|</td>
283 <td><input name="l_email" type=checkbox class=checkbox value=Y checked> |
284 . $locale->text('E-mail') . qq|</td>
287 <td><input name="l_taxnumber" type=checkbox class=checkbox value=Y> |
288 . $locale->text('Tax Number') . qq|</td>
289 <td><input name="l_sic_code" type=checkbox class=checkbox value=Y> |
290 . $locale->text('SIC') . qq|</td>
291 <td><input name="l_business" type=checkbox class=checkbox value=Y> |
292 . $locale->text('Type of Business') . qq|</td>
295 <td><input name="l_invnumber" type=checkbox class=checkbox value=Y> |
296 . $locale->text('Invoices') . qq|</td>
297 <td><input name="l_ordnumber" type=checkbox class=checkbox value=Y> |
298 . $locale->text('Orders') . qq|</td>
299 <td><input name="l_quonumber" type=checkbox class=checkbox value=Y> |
300 . $locale->text('Quotations') . qq|</td>
309 <td><hr size=3 noshade></td>
313 <input type=hidden name=nextsub value=list_names>
315 <input type=hidden name=login value=$form->{login}>
316 <input type=hidden name=password value=$form->{password}>
319 <input type=submit class=submit name=action value="|
320 . $locale->text('Continue') . qq|">
326 $lxdebug->leave_sub();
330 $lxdebug->enter_sub();
332 CT->search(\%myconfig, \%$form);
335 "$form->{script}?action=list_names&db=$form->{db}&login=$form->{login}&password=$form->{password}&status=$form->{status}&obsolete=$form->{obsolete}";
339 $form->sort_columns(id, name,
340 "$form->{db}number", address,
345 invnumber, ordnumber,
348 foreach $item (@columns) {
349 if ($form->{"l_$item"} eq "Y") {
350 push @column_index, $item;
352 # add column to href and callback
353 $callback .= "&l_$item=Y";
354 $href .= "&l_$item=Y";
358 ($form->{db} eq "customer")
359 ? $locale->text('Customer Number')
360 : $locale->text('Vendor Number');
362 if ($form->{status} eq 'all') {
363 $option = $locale->text('All');
365 if ($form->{status} eq 'orphaned') {
366 $option .= $locale->text('Orphaned');
369 $callback .= "&name=" . $form->escape($form->{name}, 1);
370 $href .= "&name=" . $form->escape($form->{name});
371 $option .= "\n<br>" . $locale->text('Name') . " : $form->{name}";
373 if ($form->{contact}) {
374 $callback .= "&contact=" . $form->escape($form->{contact}, 1);
375 $href .= "&contact=" . $form->escape($form->{contact});
376 $option .= "\n<br>" . $locale->text('Contact') . " : $form->{contact}";
378 if ($form->{"$form->{db}number"}) {
380 qq|&$form->{db}number=| . $form->escape($form->{"$form->{db}number"}, 1);
382 "&$form->{db}number=" . $form->escape($form->{"$form->{db}number"});
384 "\n<br>" . $locale->text('Number') . qq| : $form->{"$form->{db}number"}|;
386 if ($form->{email}) {
387 $callback .= "&email=" . $form->escape($form->{email}, 1);
388 $href .= "&email=" . $form->escape($form->{email});
389 $option .= "\n<br>" . $locale->text('E-mail') . " : $form->{email}";
392 $form->{callback} = "$callback&sort=$form->{sort}";
393 $callback = $form->escape($form->{callback});
396 qq|<th class=listheading>| . $locale->text('ID') . qq|</th>|;
397 $column_header{"$form->{db}number"} =
398 qq|<th><a class=listheading href=$href&sort=$form->{db}number>$number</a></th>|;
399 $column_header{name} =
400 qq|<th><a class=listheading href=$href&sort=name>|
401 . $locale->text('Name')
403 $column_header{address} =
404 qq|<th><a class=listheading href=$href&sort=address>|
405 . $locale->text('Address')
407 $column_header{contact} =
408 qq|<th><a class=listheading href=$href&sort=contact>|
409 . $locale->text('Contact')
411 $column_header{phone} =
412 qq|<th><a class=listheading href=$href&sort=phone>|
413 . $locale->text('Phone')
415 $column_header{fax} =
416 qq|<th><a class=listheading href=$href&sort=fax>|
417 . $locale->text('Fax')
419 $column_header{email} =
420 qq|<th><a class=listheading href=$href&sort=email>|
421 . $locale->text('E-mail')
424 qq|<th><a class=listheading href=$href&sort=cc>|
425 . $locale->text('Cc')
428 $column_header{taxnumber} =
429 qq|<th><a class=listheading href=$href&sort=taxnumber>|
430 . $locale->text('Tax Number')
432 $column_header{sic_code} =
433 qq|<th><a class=listheading href=$href&sort=sic_code>|
434 . $locale->text('SIC')
436 $column_header{business} =
437 qq|<th><a class=listheading href=$href&sort=business>|
438 . $locale->text('Type of Business')
441 $column_header{invnumber} =
442 qq|<th><a class=listheading href=$href&sort=invnumber>|
443 . $locale->text('Invoice')
445 $column_header{ordnumber} =
446 qq|<th><a class=listheading href=$href&sort=ordnumber>|
447 . $locale->text('Order')
449 $column_header{quonumber} =
450 qq|<th><a class=listheading href=$href&sort=quonumber>|
451 . $locale->text('Quotation')
454 $label = ucfirst $form->{db} . "s";
455 $form->{title} = $locale->text($label);
464 <th class=listtop>$form->{title}</th>
473 <tr class=listheading>
476 map { print "$column_header{$_}\n" } @column_index;
482 $ordertype = ($form->{db} eq 'customer') ? 'sales_order' : 'purchase_order';
484 ($form->{db} eq 'customer') ? 'sales_quotation' : 'request_quotation';
486 foreach $ref (@{ $form->{CT} }) {
488 if ($ref->{id} eq $sameid) {
489 map { $column_data{$_} = "<td> </td>" } @column_index;
491 map { $column_data{$_} = "<td>$ref->{$_} </td>" } @column_index;
493 map { $column_data{$_} = "<td>$ref->{$_} </td>" }
494 (invnumber, ordnumber, quonumber);
497 "<td align=left><a href=$form->{script}?action=edit&id=$ref->{id}&db=$form->{db}&login=$form->{login}&password=$form->{password}&status=$form->{status}&callback=$callback>$ref->{name} </td>";
500 $email = $ref->{email};
501 $email =~ s/</\</;
502 $email =~ s/>/\>/;
504 $column_data{email} =
505 qq|<td><a href="mailto:$ref->{email}">$email</a></td>|;
510 if ($ref->{formtype} eq 'invoice') {
511 $column_data{invnumber} =
512 "<td><a href=$ref->{module}.pl?action=edit&id=$ref->{invid}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{invnumber} </td>";
515 if ($ref->{formtype} eq 'order') {
516 $column_data{ordnumber} =
517 "<td><a href=$ref->{module}.pl?action=edit&id=$ref->{invid}&type=$ordertype&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{ordnumber} </td>";
520 if ($ref->{formtype} eq 'quotation') {
521 $column_data{quonumber} =
522 "<td><a href=$ref->{module}.pl?action=edit&id=$ref->{invid}&type=$quotationtype&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{quonumber} </td>";
531 map { print "$column_data{$_}\n" } @column_index;
537 $sameid = $ref->{id};
546 <td><hr size=3 noshade></td>
551 <form method=post action=$form->{script}>
553 <input name=callback type=hidden value="$form->{callback}">
554 <input name=db type=hidden value=$form->{db}>
556 <input type=hidden name=login value=$form->{login}>
557 <input type=hidden name=password value=$form->{password}>
559 <input class=submit type=submit name=action value="|
560 . $locale->text('Add') . qq|">
568 $lxdebug->leave_sub();
572 $lxdebug->enter_sub();
574 # show history button
575 $form->{javascript} = qq|<script type=text/javascript src=js/show_history.js></script>|;
576 #/show hhistory button
578 # $locale->text('Edit Customer')
579 # $locale->text('Edit Vendor')
581 CT->get_tuple(\%myconfig, \%$form);
582 CT->populate_drop_down_boxes(\%myconfig, \%$form);
584 # format " into "
585 map { $form->{$_} =~ s/\"/"/g } keys %$form;
587 $form->{title} = "Edit";
590 $form->{discount} *= 100;
595 $lxdebug->leave_sub();
599 $lxdebug->enter_sub();
601 $form->get_lists("employees" => "ALL_SALESMEN",
602 "taxzones" => "ALL_TAXZONES");
604 $form->{taxincluded} = ($form->{taxincluded}) ? "checked" : "";
605 $form->{creditlimit} =
606 $form->format_amount(\%myconfig, $form->{creditlimit}, 0);
607 $form->{discount} = $form->format_amount(\%myconfig, $form->{discount});
609 if ($myconfig{role} eq 'admin') {
612 <th align=right nowrap>| . $locale->text('Bcc') . qq|</th>
613 <td><input name=bcc size=35 value="$form->{bcc}"></td>
617 $form->{obsolete} = "checked" if $form->{obsolete};
619 $lang = qq|<option value=""></option>|;
620 foreach $item (@{ $form->{languages} }) {
621 if ($form->{language_id} eq $item->{id}) {
622 $lang .= qq|<option value="$item->{id}" selected>$item->{description}</option>|;
624 $lang .= qq|<option value="$item->{id}">$item->{description}</option>|;
628 $payment = qq|<option value=""></option>|;
629 foreach $item (@{ $form->{payment_terms} }) {
630 if ($form->{payment_id} eq $item->{id}) {
631 $payment .= qq|<option value="$item->{id}" selected>$item->{description}</option>|;
633 $payment .= qq|<option value="$item->{id}">$item->{description}</option>|;
638 if ($form->{db} eq "customer") {
639 $form->{taxzone_id} = 0;
641 $form->{taxzone_id} = 0;
647 foreach my $item (@{ $form->{"ALL_TAXZONES"} }) {
648 push(@values, $item->{"id"});
649 $labels{$item->{"id"}} = $item->{"description"};
653 <th align=right>| . $locale->text('Steuersatz') . qq|</th>
655 NTI($cgi->popup_menu('-name' => 'taxzone_id', '-default' => $form->{"taxzone_id"},
656 '-values' => \@values, '-labels' => \%labels)) . qq|
661 "$form->{script}?login=$form->{login}&password=$form->{password}&action=get_contact";
663 my $pjx = new CGI::Ajax( 'get_contact' => $get_contact_url );
664 $form->{selectcontact} = "<option value=0></option>";
665 if (@{ $form->{CONTACTS} }) {
666 foreach $item (@{ $form->{CONTACTS} }) {
667 if ($item->{cp_id} == $form->{cp_id}) {
668 $form->{selectcontact} .=
669 qq|<option value=$item->{cp_id} selected>$item->{cp_name}</option>\n|;
671 $form->{selectcontact} .=
672 qq|<option value=$item->{cp_id}>$item->{cp_name}</option>\n|;
677 push(@ { $form->{AJAX} }, $pjx);
678 $ansprechpartner = qq|
680 <th align=right>| . $locale->text('Ansprechpartner') . qq|</th>
681 <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>
682 <input type=hidden name=selectcontact value="$form->{selectcontact}">
685 "$form->{script}?login=$form->{login}&password=$form->{password}&action=get_shipto";
687 my $pjy = new CGI::Ajax( 'get_shipto' => $get_shipto_url );
688 $form->{selectshipto} = "<option value=0></option>";
689 $form->{selectshipto} .= "<option value=0>Alle</option>";
690 if (@{ $form->{SHIPTO} }) {
691 foreach $item (@{ $form->{SHIPTO} }) {
692 if ($item->{shipto_id} == $form->{shipto_id}) {
693 $form->{selectshipto} .=
694 "<option value=$item->{shipto_id} selected>$item->{shiptoname} $item->{shiptodepartment_1}\n";
696 $form->{selectshipto} .=
697 "<option value=$item->{shipto_id}>$item->{shiptoname} $item->{shiptodepartment_1}\n";
702 push(@ { $form->{AJAX} }, $pjy);
706 <th align=right>| . $locale->text('Shipping Address') . qq|</th>
707 <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>
708 <input type=hidden name=selectshipto value="$form->{selectshipto}">
713 "$form->{script}?login=$form->{login}&password=$form->{password}&action=get_delivery";
715 my $pjz = new CGI::Ajax( 'get_delivery' => $get_delivery_url );
717 push(@ { $form->{AJAX} }, $pjz);
721 <th align=right>| . $locale->text('Shipping Address') . qq|</th>
722 <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>
725 $form->{selectbusiness} = qq|<option>\n|;
727 $form->{selectbusiness} .=
728 qq|<option value=$_->{id}>$_->{description}\n|
729 } @{ $form->{all_business} };
730 if ($form->{business_save}) {
731 $form->{selectbusiness} = $form->{business_save};
733 $form->{selectbusiness} =~
734 s/<option value=$form->{business}>/<option value=$form->{business} selected>/;
736 $label = ucfirst $form->{db};
737 if ($form->{title} eq "Edit") {
738 $form->{title} = $locale->text("$form->{title} $label") . " $form->{name}";
740 $form->{title} = $locale->text("$form->{title} $label");
742 if ($form->{title_save}) {
743 $form->{title} = $form->{title_save};
745 if ($form->{db} eq 'vendor') {
747 <th align=right>| . $locale->text('Kundennummer') . qq|</th>
748 <td><input name=v_customer_id size=10 maxlength=35 value="$form->{v_customer_id}"></td>
752 if ($form->{db} eq 'customer') {
755 <th align=right>| . $locale->text('KNr. beim Kunden') . qq|</th>
756 <td><input name=c_vendor_id size=10 maxlength=35 value="$form->{c_vendor_id}"></td>
761 <th align=right>| . $locale->text('Type of Business') . qq|</th>
762 <td><select name=business>$form->{selectbusiness}</select></td>
767 if ($form->{db} eq "customer") {
768 my (@salesman_values, %salesman_labels);
769 push(@salesman_values, undef);
770 foreach my $item (@{ $form->{ALL_SALESMEN} }) {
771 push(@salesman_values, $item->{id});
772 $salesman_labels{$item->{id}} = $item->{name} ne "" ? $item->{name} : $item->{login};
776 qq| <th align="right">| . $locale->text('Salesman') . qq|</th>
778 NTI($cgi->popup_menu('-name' => 'salesman_id', '-default' => $form->{salesman_id},
779 '-values' => \@salesman_values, '-labels' => \%salesman_labels))
783 ## LINET: Create a drop-down box with all prior titles and greetings.
784 CT->query_titles_and_greetings(\%myconfig, \%$form);
786 $select_title = qq| <select name=selected_cp_title><option></option>|;
787 map({ $select_title .= qq|<option>$_</option>|; } @{ $form->{TITLES} });
788 $select_title .= qq|</select>|;
791 qq| <select name=selected_cp_greeting><option></option>|;
793 { $select_greeting .= qq|<option>$_</option>|; } @{ $form->{GREETINGS} });
794 $select_greeting .= qq|</select>|;
796 $select_company_greeting =
797 qq| <select name=selected_company_greeting><option></option>|;
799 { $select_company_greeting .= qq|<option>$_</option>|; } @{ $form->{COMPANY_GREETINGS} });
800 $select_company_greeting .= qq|</select>|;
803 qq| <select name=selected_cp_abteilung><option></option>|;
805 { $select_department .= qq|<option>$_</option>|; } @{ $form->{DEPARTMENT} });
806 $select_department .= qq|</select>|;
809 if ($form->{db} eq 'customer') {
811 #get pricegroup and form it
812 $form->get_pricegroup(\%myconfig, { all => 1 });
814 $form->{pricegroup} = "$form->{klass}";
815 $form->{pricegroup_id} = "$form->{klass}";
817 if (@{ $form->{all_pricegroup} }) {
819 $form->{selectpricegroup} = qq|<option>\n|;
821 $form->{selectpricegroup} .=
822 qq|<option value="$_->{id}">$_->{pricegroup}\n|
823 } @{ $form->{all_pricegroup} };
826 if ($form->{selectpricegroup}) {
827 $form->{selectpricegroup} = $form->unescape($form->{selectpricegroup});
830 qq|<input type=hidden name=selectpricegroup value="|
831 . $form->escape($form->{selectpricegroup}, 1) . qq|">|;
833 $form->{selectpricegroup} =~
834 s/(<option value="\Q$form->{klass}\E")/$1 selected/;
837 qq|<select name=klass>$form->{selectpricegroup}</select>|;
842 # $locale->text('Customer Number')
843 # $locale->text('Vendor Number')
844 $form->{fokus} = "ct.greeting";
845 $form->{jsscript} = 1;
849 <body onLoad="fokus()">
852 <th class=listtop>$form->{title}</th>
857 <form method=post name="ct" action=$form->{script} onKeyUp="highlight(event)" onClick="highlight(event)">
861 <ul id="maintab" class="shadetabs">
862 <li class="selected"><a href="#" rel="billing">|
863 . $locale->text('Billing Address') . qq|</a></li>
864 <li><a href="#" rel="shipto">|
865 . $locale->text('Shipping Address') . qq|</a></li>
866 <li><a href="#" rel="contacts">Ansprechpartner</a></li>
867 <li><a href="#" rel="deliveries">|
868 . $locale->text('Lieferungen') . qq|</a></li>
872 <div class="tabcontentstyle">
874 <div id="billing" class="tabcontent">
879 <th align=right nowrap>| . $locale->text($label . ' Number') . qq|</th>
880 <td><input name="$form->{db}number" size=35 maxlength=35 value="$form->{"$form->{db}number"}"></td>
883 <th align=right nowrap>| . $locale->text('Greeting') . qq|</th>
884 <td><input id=greeting name=greeting size=30 maxlength=30 value="$form->{greeting}">
885 $select_company_greeting</td>
888 <th align=right nowrap>| . $locale->text('Company Name') . qq|</th>
889 <td><input name=name size=35 maxlength=75 value="$form->{name}"></td>
892 <th align=right nowrap>| . $locale->text('Abteilung') . qq|</th>
893 <td><input name=department_1 size=16 maxlength=75 value="$form->{department_1}">
894 <input name=department_2 size=16 maxlength=75 value="$form->{department_2}"></td>
897 <th align=right nowrap>| . $locale->text('Street') . qq|</th>
898 <td><input name=street size=35 maxlength=75 value="$form->{street}"></td>
901 <th align=right nowrap>|
902 . $locale->text('Zipcode') . "/" . $locale->text('City') . qq|</th>
903 <td><input name=zipcode size=5 maxlength=10 value="$form->{zipcode}">
904 <input name=city size=30 maxlength=75 value="$form->{city}"></td>
907 <th align=right nowrap>| . $locale->text('Country') . qq|</th>
908 <td><input name=country size=35 maxlength=75 value="$form->{country}"></td>
911 <th align=right nowrap>| . $locale->text('Contact') . qq|</th>
912 <td><input name=contact size=28 maxlength=75 value="$form->{contact}"></td>
915 <th align=right nowrap>| . $locale->text('Phone') . qq|</th>
916 <td><input name=phone size=30 maxlength=30 value="$form->{phone}"></td>
919 <th align=right nowrap>| . $locale->text('Fax') . qq|</th>
920 <td><input name=fax size=30 maxlength=30 value="$form->{fax}"></td>
923 <th align=right nowrap>| . $locale->text('E-mail') . qq|</th>
924 <td><input name=email size=45 value="$form->{email}"></td>
927 <th align=right nowrap>| . $locale->text('Homepage') . qq|</th>
928 <td><input name=homepage size=45 value="$form->{homepage}"></td>
933 <th align=right>| . $locale->text('Credit Limit') . qq|</th>
934 <td><input name=creditlimit size=9 value="$form->{creditlimit}"></td>
935 <input type="hidden" name="terms" value="$form->{terms}">
936 <th align=right>| . $locale->text('Payment Terms') . qq|</th>
937 <td><select name=payment_id>$payment</select></td>
938 <th align=right>| . $locale->text('Discount') . qq|</th>
939 <td><input name=discount size=4 value="$form->{discount}">
943 <th align=right>| . $locale->text('Tax Number / SSN') . qq|</th>
944 <td><input name=taxnumber size=20 value="$form->{taxnumber}"></td>
945 <th align=right>| . $locale->text('USt-IdNr.') . qq|</th>
946 <td><input name="ustid" maxlength="14" size="20" value="$form->{ustid}"></td>
950 <th align=right>| . $locale->text('Account Number') . qq|</th>
951 <td><input name=account_number size=10 value="$form->{account_number}"></td>
952 <th align=right>| . $locale->text('Bank Code Number') . qq|</th>
953 <td><input name=bank_code size=10 value="$form->{bank_code}"></td>
954 <th align=right>| . $locale->text('Bank') . qq|</th>
955 <td><input name=bank size=30 value="$form->{bank}"></td>
959 <th align=right>| . $locale->text('Language') . qq|</th>
960 <td><select name=language_id>$lang
963 if ($form->{db} eq 'customer') {
966 <th align=right>| . $locale->text('Preisklasse') . qq|</th>
967 <td>$pricegroup</td>|;
971 <td align=right>| . $locale->text('Obsolete') . qq|</td>
972 <td><input name=obsolete class=checkbox type=checkbox value=1 $form->{obsolete}></td>
981 <th align=left nowrap>| . $locale->text('Notes') . qq|</th>
984 <td><textarea name=notes rows=3 cols=60 wrap=soft>$form->{notes}</textarea></td>
991 <br style="clear: left" /></div>|;
994 <div id="shipto" class="tabcontent">
999 <th align=right nowrap>| . $locale->text('Company Name') . qq|</th>
1000 <td><input id=shiptoname name=shiptoname size=35 maxlength=75 value="$form->{shiptoname}"></td>
1003 <th align=right nowrap>| . $locale->text('Abteilung') . qq|</th>
1004 <td><input id=shiptodepartment_1 name=shiptodepartment_1 size=16 maxlength=75 value="$form->{shiptodepartment_1}">
1005 <input id=shiptodepartment_2 name=shiptodepartment_2 size=16 maxlength=75 value="$form->{shiptodepartment_2}"></td>
1008 <th align=right nowrap>| . $locale->text('Street') . qq|</th>
1009 <td><input id=shiptostreet name=shiptostreet size=35 maxlength=75 value="$form->{shiptostreet}"></td>
1012 <th align=right nowrap>|
1013 . $locale->text('Zipcode') . "/" . $locale->text('City') . qq|</th>
1014 <td><input id=shiptozipcode name=shiptozipcode size=5 maxlength=10 value="$form->{shiptozipcode}">
1015 <input id=shiptocity name=shiptocity size=30 maxlength=75 value="$form->{shiptocity}"></td>
1018 <th align=right nowrap>| . $locale->text('Country') . qq|</th>
1019 <td><input id=shiptocountry name=shiptocountry size=35 maxlength=35 value="$form->{shiptocountry}"></td>
1022 <th align=right nowrap>| . $locale->text('Contact') . qq|</th>
1023 <td><input id=shiptocontact name=shiptocontact size=30 maxlength=75 value="$form->{shiptocontact}"></td>
1026 <th align=right nowrap>| . $locale->text('Phone') . qq|</th>
1027 <td><input id=shiptophone name=shiptophone size=30 maxlength=30 value="$form->{shiptophone}"></td>
1030 <th align=right nowrap>| . $locale->text('Fax') . qq|</th>
1031 <td><input id=shiptofax name=shiptofax size=30 maxlength=30 value="$form->{shiptofax}"></td>
1034 <th align=right nowrap>| . $locale->text('E-mail') . qq|</th>
1035 <td><input id=shiptoemail name=shiptoemail size=45 value="$form->{shiptoemail}"></td>
1045 <br style="clear: left" /></div>|;
1048 ##LINET - added fields for contact person
1050 <div id="contacts" class="tabcontent">
1054 <input type=hidden name=cp_id value=$form->{cp_id}>
1058 <th align=left nowrap>| . $locale->text('Greeting') . qq|</th>
1059 <td><input id=cp_greeting name=cp_greeting size=40 maxlength=40 value="$form->{cp_greeting}">
1060 $select_greeting</td>
1063 <th align=left nowrap>| . $locale->text('Title') . qq|</th>
1064 <td><input id=cp_title name=cp_title size=40 maxlength=40 value="$form->{cp_title}">
1068 <th align=left nowrap>| . $locale->text('Department') . qq|</th>
1069 <td><input id=cp_abteilung name=cp_abteilung size=40 maxlength=40 value="$form->{cp_abteilung}">
1070 $select_department</td>
1073 <th align=left nowrap>|
1074 . $locale->text('Given Name') . qq|</th>
1075 <td><input id=cp_givenname name=cp_givenname size=40 maxlength=40 value="$form->{cp_givenname}"></td>
1078 <th align=left nowrap>| . $locale->text('Name') . qq|</th>
1079 <td><input id=cp_name name=cp_name size=40 maxlength=40 value="$form->{cp_name}"></td>
1082 <th align=left nowrap>| . $locale->text('Phone1') . qq|</th>
1083 <td><input id=cp_phone1 name=cp_phone1 size=40 maxlength=40 value="$form->{cp_phone1}"></td>
1086 <th align=left nowrap>| . $locale->text('Phone2') . qq|</th>
1087 <td><input id=cp_phone2 name=cp_phone2 size=40 maxlength=40 value="$form->{cp_phone2}"></td>
1090 <th align=left nowrap>| . $locale->text('Fax') . qq|</th>
1091 <td><input id=cp_fax name=cp_fax size=40 maxlength=40 value="$form->{cp_fax}"></td>
1094 <th align=left nowrap>| . $locale->text('Mobile1') . qq|</th>
1095 <td><input id=cp_mobile1 name=cp_mobile1 size=40 maxlength=40 value="$form->{cp_mobile1}"></td>
1098 <th align=left nowrap>| . $locale->text('Mobile2') . qq|</th>
1099 <td><input id=cp_mobile2 name=cp_mobile2 size=40 maxlength=40 value="$form->{cp_mobile2}"></td>
1102 <th align=left nowrap>| . $locale->text('Sat. Phone') . qq|</th>
1103 <td><input id=cp_satphone name=cp_satphone size=40 maxlength=40 value="$form->{cp_satphone}"></td>
1106 <th align=left nowrap>| . $locale->text('Sat. Fax') . qq|</th>
1107 <td><input id=cp_satfax name=cp_satfax size=40 maxlength=40 value="$form->{cp_satfax}"></td>
1110 <th align=left nowrap>| . $locale->text('Project') . qq|</th>
1111 <td><input id=cp_project name=cp_project size=40 maxlength=40 value="$form->{cp_project}"></td>
1114 <th align=left nowrap>| . $locale->text('E-mail') . qq|</th>
1115 <td><input id=cp_email name=cp_email size=40 maxlength=40 value="$form->{cp_email}"></td>
1118 <th align=left nowrap>| . $locale->text('Private Phone') . qq|</th>
1119 <td><input id=cp_privatphone name=cp_privatphone size=40 maxlength=40 value="$form->{cp_privatphone}"></td>
1122 <th align=left nowrap>| . $locale->text('Private E-mail') . qq|</th>
1123 <td><input id=cp_privatemail name=cp_privatemail size=40 maxlength=40 value="$form->{cp_privatemail}"></td>
1126 <th align=left nowrap>| . $locale->text('Birthday') . qq|</th>
1127 <td><input id=cp_birthday name=cp_birthday size=40 maxlength=40 value="$form->{cp_birthday}"></td>
1133 <tr height="5"></tr>|;
1143 <br style="clear: left" /></div>
1144 <div id="deliveries" class="tabcontent">
1148 <th align=left nowrap>| . $locale->text('From') . qq|</th>
1149 <td><input id=from name=from size=10 maxlength=10 value="$form->{from}">
1150 <input type="button" name="fromB" id="trigger_from" value="?"></td>
1151 <th align=left nowrap>| . $locale->text('To (time)') . qq|</th>
1152 <td><input id=to name=to size=10 maxlength=10 value="$form->{to}">
1153 <input type="button" name="toB" id="trigger_to" value="?"></td>
1162 <br style="clear: left" /></div>
1166 | . $form->write_trigger(\%myconfig, 2, "fromB", "BL", "trigger_from",
1167 "toB", "BL", "trigger_to");
1169 $lxdebug->leave_sub();
1173 $lxdebug->enter_sub();
1175 $label = ucfirst $form->{db};
1177 ($form->{db} eq 'customer')
1178 ? $locale->text('Save and Quotation')
1179 : $locale->text('Save and RFQ');
1181 ($form->{db} eq 'customer')
1182 ? $locale->text('Save and AR Transaction')
1183 : $locale->text('Save and AP Transaction');
1185 ##<input class=submit type=submit name=action value="|.$locale->text("Save and Quotation").qq|">
1186 ##<input class=submit type=submit name=action value="|.$locale->text("Save and RFQ").qq|">
1187 ##<input class=submit type=submit name=action value="|.$locale->text("Save and AR Transaction").qq|">
1188 ##<input class=submit type=submit name=action value="|.$locale->text("Save and AP Transaction").qq|">
1191 <input name=id type=hidden id=cvid value=$form->{id}>
1192 <input name=business_save type=hidden value="$form->{selectbusiness}">
1193 <input name=title_save type=hidden value="$form->{title}">
1195 <input type=hidden name=login value=$form->{login}>
1196 <input type=hidden name=password value=$form->{password}>
1198 <input type=hidden name=callback value="$form->{callback}">
1199 <input type=hidden name=db id=db value=$form->{db}>
1204 <input class=submit type=submit name=action accesskey="s" value="|
1205 . $locale->text("Save") . qq|">
1206 <input class=submit type=submit name=action accesskey="s" value="|
1207 . $locale->text("Save and Close") . qq|">
1208 <input class=submit type=submit name=action value="$arap">
1209 <input class=submit type=submit name=action value="|
1210 . $locale->text("Save and Invoice") . qq|">
1211 <input class=submit type=submit name=action value="|
1212 . $locale->text("Save and Order") . qq|">
1213 <input class=submit type=submit name=action value="$quotation">
1216 if ($form->{id} && $form->{status} eq 'orphaned') {
1217 print qq|<input class=submit type=submit name=action value="|
1218 . $locale->text('Delete')
1222 # button for saving history
1223 if($form->{id} ne "") {
1225 <input type=button class=submit onclick=set_history_window(|
1227 . qq|); name=history id=history value=|
1228 . $locale->text('history')
1231 # /button for saving history
1236 <script type="text/javascript">
1237 //Start Tab Content script for UL with id="maintab" Separate multiple ids each with a comma.
1238 initializetabcontent("maintab")
1244 $lxdebug->leave_sub();
1247 sub add_transaction {
1248 $lxdebug->enter_sub();
1250 # # saving the history
1251 # if(!exists $form->{addition}) {
1252 # $form->{addition} = "ADD TRANSACTION";
1253 # $form->save_history($form->dbconnect(\%myconfig));
1255 # # /saving the history
1257 $form->isblank("name", $locale->text("Name missing!"));
1258 if ($form->{"db"} eq "customer") {
1259 CT->save_customer(\%myconfig, \%$form);
1261 CT->save_vendor(\%myconfig, \%$form);
1264 $form->{callback} = $form->escape($form->{callback}, 1);
1265 $name = $form->escape("$form->{name}", 1);
1268 "$form->{script}?login=$form->{login}&password=$form->{password}&action=add&vc=$form->{db}&$form->{db}_id=$form->{id}&$form->{db}=$name&type=$form->{type}&callback=$form->{callback}";
1271 $lxdebug->leave_sub();
1274 sub save_and_ap_transaction {
1275 $lxdebug->enter_sub();
1277 $form->{script} = "ap.pl";
1278 # saving the history
1279 if(!exists $form->{addition}) {
1280 $form->{snumbers} = qq|invnumber_| . $form->{invnumber};
1281 $form->{addition} = "SAVED";
1282 $form->save_history($form->dbconnect(\%myconfig));
1284 # /saving the history
1286 $lxdebug->leave_sub();
1289 sub save_and_ar_transaction {
1290 $lxdebug->enter_sub();
1292 $form->{script} = "ar.pl";
1293 # saving the history
1294 if(!exists $form->{addition}) {
1295 $form->{snumbers} = qq|invnumber_| . $form->{invnumber};
1296 $form->{addition} = "SAVED";
1297 $form->save_history($form->dbconnect(\%myconfig));
1299 # /saving the history
1301 $lxdebug->leave_sub();
1304 sub save_and_invoice {
1305 $lxdebug->enter_sub();
1307 $form->{script} = ($form->{db} eq 'customer') ? "is.pl" : "ir.pl";
1308 $form->{type} = "invoice";
1309 # saving the history
1310 if(!exists $form->{addition}) {
1311 $form->{snumbers} = qq|invnumber_| . $form->{invnumber};
1312 $form->{addition} = "SAVED";
1313 $form->save_history($form->dbconnect(\%myconfig));
1315 # /saving the history
1317 $lxdebug->leave_sub();
1321 $lxdebug->enter_sub();
1323 $form->{script} = "oe.pl";
1324 $form->{type} = "request_quotation";
1325 # saving the history
1326 if(!exists $form->{addition}) {
1327 $form->{snumbers} = qq|ordnumber_| . $form->{ordnumber};
1328 $form->{addition} = "SAVED";
1329 $form->save_history($form->dbconnect(\%myconfig));
1331 # /saving the history
1333 $lxdebug->leave_sub();
1336 sub save_and_quotation {
1337 $lxdebug->enter_sub();
1339 $form->{script} = "oe.pl";
1340 $form->{type} = "sales_quotation";
1341 # saving the history
1342 if(!exists $form->{addition}) {
1343 $form->{snumbers} = qq|ordnumber_| . $form->{ordnumber};
1344 $form->{addition} = "SAVED";
1345 $form->save_history($form->dbconnect(\%myconfig));
1347 # /saving the history
1349 $lxdebug->leave_sub();
1352 sub save_and_order {
1353 $lxdebug->enter_sub();
1355 $form->{script} = "oe.pl";
1357 ($form->{db} eq 'customer') ? "sales_order" : "purchase_order";
1358 # saving the history
1359 if(!exists $form->{addition}) {
1360 $form->{snumbers} = qq|ordnumber_| . $form->{ordnumber};
1361 $form->{addition} = "SAVED";
1362 $form->save_history($form->dbconnect(\%myconfig));
1364 # /saving the history
1366 $lxdebug->leave_sub();
1369 sub save_and_close {
1370 $lxdebug->enter_sub();
1372 # $locale->text('Customer saved!')
1373 # $locale->text('Vendor saved!')
1375 $msg = ucfirst $form->{db};
1378 $form->isblank("name", $locale->text("Name missing!"));
1379 if ($form->{"db"} eq "customer") {
1380 $rc = CT->save_customer(\%myconfig, \%$form);
1382 $rc = CT->save_vendor(\%myconfig, \%$form);
1385 $form->error($locale->text('customernumber not unique!'));
1387 # saving the history
1388 if(!exists $form->{addition}) {
1389 $form->{snumbers} = ($form->{"db"} eq "customer" ? qq|customernumber_| . $form->{customernumber} : qq|vendornumber_| . $form->{vendornumber});
1390 $form->{addition} = "SAVED";
1391 $form->save_history($form->dbconnect(\%myconfig));
1393 # /saving the history
1394 $form->redirect($locale->text($msg));
1396 $lxdebug->leave_sub();
1400 $lxdebug->enter_sub();
1402 # $locale->text('Customer saved!')
1403 # $locale->text('Vendor saved!')
1405 $msg = ucfirst $form->{db};
1408 $form->isblank("name", $locale->text("Name missing!"));
1411 if ($form->{"db"} eq "customer") {
1412 $res = CT->save_customer(\%myconfig, \%$form);
1414 $res = CT->save_vendor(\%myconfig, \%$form);
1418 if ($form->{"db"} eq "customer") {
1419 $form->error($locale->text('This customer number is already in use.'));
1421 $form->error($locale->text('This vendor number is already in use.'));
1424 # saving the history
1425 if(!exists $form->{addition}) {
1426 $form->{snumbers} = ($form->{"db"} eq "customer" ? qq|customernumber_| . $form->{customernumber} : qq|vendornumber_| . $form->{vendornumber});
1427 $form->{addition} = "SAVED";
1428 $form->save_history($form->dbconnect(\%myconfig));
1430 # /saving the history
1433 $lxdebug->leave_sub();
1437 $lxdebug->enter_sub();
1439 # $locale->text('Customer deleted!')
1440 # $locale->text('Cannot delete customer!')
1441 # $locale->text('Vendor deleted!')
1442 # $locale->text('Cannot delete vendor!')
1444 CT->delete(\%myconfig, \%$form);
1446 $msg = ucfirst $form->{db};
1447 $msg .= " deleted!";
1448 # saving the history
1449 if(!exists $form->{addition}) {
1450 $form->{snumbers} = ($form->{"db"} eq "customer" ? qq|customernumber_| . $form->{customernumber} : qq|vendornumber_| . $form->{vendornumber});
1451 $form->{addition} = "DELETED";
1452 $form->save_history($form->dbconnect(\%myconfig));
1454 # /saving the history
1455 $form->redirect($locale->text($msg));
1457 $msg = "Cannot delete $form->{db}";
1458 $form->error($locale->text($msg));
1460 $lxdebug->leave_sub();
1464 $lxdebug->enter_sub();
1469 $lxdebug->leave_sub();
1473 $lxdebug->enter_sub();
1476 $lxdebug->leave_sub();
1480 $lxdebug->enter_sub();
1482 CT->get_contact(\%myconfig, \%$form);
1485 $result = "$form->{cp_name}";
1486 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);
1489 $lxdebug->leave_sub();
1494 $lxdebug->enter_sub();
1496 CT->get_shipto(\%myconfig, \%$form);
1499 $result = "$form->{shiptoname}";
1500 map { $result .= "__pjx__" . $form->{$_} } qw(shiptodepartment_1 shiptodepartment_2 shiptostreet shiptozipcode shiptocity shiptocountry shiptocontact shiptophone shiptofax shiptoemail);
1503 $lxdebug->leave_sub();
1508 $lxdebug->enter_sub();
1510 CT->get_delivery(\%myconfig, \%$form );
1513 $form->sort_columns(shiptoname,
1523 $column_header{shiptoname} =
1524 qq|<th class=listheading>| . $locale->text('Shipping Address') . qq|</th>|;
1525 $column_header{invnumber} =
1526 qq|<th class=listheading>|. $locale->text('Invoice'). qq|</th>|;
1527 $column_header{ordnumber} =
1528 qq|<th class=listheading>|. $locale->text('Order'). qq|</th>|;
1529 $column_header{transdate} =
1530 qq|<th class=listheading>| . $locale->text('Invdate') . qq|</th>|;
1531 $column_header{description} =
1532 qq|<th class=listheading>| . $locale->text('Description') . qq|</th>|;
1533 $column_header{qty} =
1534 qq|<th class=listheading>| . $locale->text('Qty') . qq|</th>|;
1535 $column_header{unit} =
1536 qq|<th class=listheading>| . $locale->text('Unit') . qq|</th>|;
1543 <tr class=listheading>
1546 map { $result .= "$column_header{$_}\n" } @column_index;
1553 foreach $ref (@{ $form->{DELIVERY} }) {
1555 if ($ref->{shiptoname} eq $sameshiptoname) {
1556 map { $column_data{$_} = "<td>$ref->{$_} </td>" } @column_index;
1557 $column_data{shiptoname} = "<td> </td>";
1559 map { $column_data{$_} = "<td>$ref->{$_} </td>" } @column_index;
1565 <tr class=listrow$i>
1568 map { $result .= "$column_data{$_}\n" } @column_index;
1574 $sameshiptoname = $ref->{shiptoname};
1586 $lxdebug->leave_sub();
1590 sub continue { call_sub($form->{nextsub}); }