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')
47 $lxdebug->enter_sub();
49 $form->{title} = "Add";
52 "$form->{script}?action=add&db=$form->{db}&path=$form->{path}&login=$form->{login}&password=$form->{password}"
53 unless $form->{callback};
55 CT->taxaccounts(\%myconfig, \%$form);
60 $lxdebug->leave_sub();
64 $lxdebug->enter_sub();
66 $label = ucfirst $form->{db};
67 $form->{title} = $locale->text($label . "s");
69 if ($form->{db} eq 'vendor') {
71 <td><input name="l_gifi_accno" type=checkbox class=checkbox value=Y> |
72 . $locale->text('GIFI') . qq|</td>
81 <form method=post action=$form->{script}>
83 <input type=hidden name=db value=$form->{db}>
87 <th class=listtop>$form->{title}</th>
94 <th align=right nowrap>| . $locale->text($label . ' Number') . qq|</th>
95 <td><input name=$form->{db}number size=35></td>
98 <th align=right nowrap>| . $locale->text('Company Name') . qq|</th>
99 <td><input name=name size=35></td>
102 <th align=right nowrap>| . $locale->text('Contact') . qq|</th>
103 <td><input name=contact size=35></td>
106 <th align=right nowrap>| . $locale->text('E-mail') . qq|</th>
107 <td><input name=email size=35></td>
111 <td><input name=status class=radio type=radio value=all checked> |
112 . $locale->text('All') . qq|
113 <input name=status class=radio type=radio value=orphaned> |
114 . $locale->text('Orphaned') . qq|</td>
117 <th align=right nowrap>| . $locale->text('Include in Report') . qq|</th>
121 <td><input name="l_id" type=checkbox class=checkbox value=Y> |
122 . $locale->text('ID') . qq|</td>
123 <td><input name="l_$form->{db}number" type=checkbox class=checkbox value=Y> |
124 . $locale->text($label . ' Number') . qq|</td>
125 <td><input name="l_name" type=checkbox class=checkbox value=Y checked> |
126 . $locale->text('Company Name') . qq|</td>
127 <td><input name="l_address" type=checkbox class=checkbox value=Y> |
128 . $locale->text('Address') . qq|</td>
131 <td><input name="l_contact" type=checkbox class=checkbox value=Y checked> |
132 . $locale->text('Contact') . qq|</td>
133 <td><input name="l_phone" type=checkbox class=checkbox value=Y checked> |
134 . $locale->text('Phone') . qq|</td>
135 <td><input name="l_fax" type=checkbox class=checkbox value=Y> |
136 . $locale->text('Fax') . qq|</td>
137 <td><input name="l_email" type=checkbox class=checkbox value=Y checked> |
138 . $locale->text('E-mail') . qq|</td>
141 <td><input name="l_taxnumber" type=checkbox class=checkbox value=Y> |
142 . $locale->text('Tax Number') . qq|</td>
144 <td><input name="l_sic_code" type=checkbox class=checkbox value=Y> |
145 . $locale->text('SIC') . qq|</td>
146 <td><input name="l_business" type=checkbox class=checkbox value=Y> |
147 . $locale->text('Type of Business') . qq|</td>
150 <td><input name="l_invnumber" type=checkbox class=checkbox value=Y> |
151 . $locale->text('Invoices') . qq|</td>
152 <td><input name="l_ordnumber" type=checkbox class=checkbox value=Y> |
153 . $locale->text('Orders') . qq|</td>
154 <td><input name="l_quonumber" type=checkbox class=checkbox value=Y> |
155 . $locale->text('Quotations') . qq|</td>
164 <td><hr size=3 noshade></td>
168 <input type=hidden name=nextsub value=list_names>
170 <input type=hidden name=path value=$form->{path}>
171 <input type=hidden name=login value=$form->{login}>
172 <input type=hidden name=password value=$form->{password}>
175 <input type=submit class=submit name=action value="|
176 . $locale->text('Continue') . qq|">
182 $lxdebug->leave_sub();
186 $lxdebug->enter_sub();
188 CT->search(\%myconfig, \%$form);
191 "$form->{script}?action=list_names&db=$form->{db}&path=$form->{path}&login=$form->{login}&password=$form->{password}&status=$form->{status}";
195 $form->sort_columns(id, name,
196 "$form->{db}number", address,
199 taxnumber, gifi_accno,
201 invnumber, ordnumber,
204 foreach $item (@columns) {
205 if ($form->{"l_$item"} eq "Y") {
206 push @column_index, $item;
208 # add column to href and callback
209 $callback .= "&l_$item=Y";
210 $href .= "&l_$item=Y";
214 ($form->{db} eq "customer")
215 ? $locale->text('Customer Number')
216 : $locale->text('Vendor Number');
218 if ($form->{status} eq 'all') {
219 $option = $locale->text('All');
221 if ($form->{status} eq 'orphaned') {
222 $option .= $locale->text('Orphaned');
225 $callback .= "&name=" . $form->escape($form->{name}, 1);
226 $href .= "&name=" . $form->escape($form->{name});
227 $option .= "\n<br>" . $locale->text('Name') . " : $form->{name}";
229 if ($form->{contact}) {
230 $callback .= "&contact=" . $form->escape($form->{contact}, 1);
231 $href .= "&contact=" . $form->escape($form->{contact});
232 $option .= "\n<br>" . $locale->text('Contact') . " : $form->{contact}";
234 if ($form->{"$form->{db}number"}) {
236 qq|&$form->{db}number=| . $form->escape($form->{"$form->{db}number"}, 1);
238 "&$form->{db}number=" . $form->escape($form->{"$form->{db}number"});
240 "\n<br>" . $locale->text('Number') . qq| : $form->{"$form->{db}number"}|;
242 if ($form->{email}) {
243 $callback .= "&email=" . $form->escape($form->{email}, 1);
244 $href .= "&email=" . $form->escape($form->{email});
245 $option .= "\n<br>" . $locale->text('E-mail') . " : $form->{email}";
248 $form->{callback} = "$callback&sort=$form->{sort}";
249 $callback = $form->escape($form->{callback});
252 qq|<th class=listheading>| . $locale->text('ID') . qq|</th>|;
253 $column_header{"$form->{db}number"} =
254 qq|<th><a class=listheading href=$href&sort=$form->{db}number>$number</a></th>|;
255 $column_header{name} =
256 qq|<th><a class=listheading href=$href&sort=name>|
257 . $locale->text('Name')
259 $column_header{address} =
260 qq|<th><a class=listheading href=$href&sort=address>|
261 . $locale->text('Address')
263 $column_header{contact} =
264 qq|<th><a class=listheading href=$href&sort=contact>|
265 . $locale->text('Contact')
267 $column_header{phone} =
268 qq|<th><a class=listheading href=$href&sort=phone>|
269 . $locale->text('Phone')
271 $column_header{fax} =
272 qq|<th><a class=listheading href=$href&sort=fax>|
273 . $locale->text('Fax')
275 $column_header{email} =
276 qq|<th><a class=listheading href=$href&sort=email>|
277 . $locale->text('E-mail')
280 qq|<th><a class=listheading href=$href&sort=cc>|
281 . $locale->text('Cc')
284 $column_header{taxnumber} =
285 qq|<th><a class=listheading href=$href&sort=taxnumber>|
286 . $locale->text('Tax Number')
288 $column_header{gifi_accno} =
289 qq|<th><a class=listheading href=$href&sort=gifi_accno>|
290 . $locale->text('GIFI')
292 $column_header{sic_code} =
293 qq|<th><a class=listheading href=$href&sort=sic_code>|
294 . $locale->text('SIC')
296 $column_header{business} =
297 qq|<th><a class=listheading href=$href&sort=business>|
298 . $locale->text('Type of Business')
301 $column_header{invnumber} =
302 qq|<th><a class=listheading href=$href&sort=invnumber>|
303 . $locale->text('Invoice')
305 $column_header{ordnumber} =
306 qq|<th><a class=listheading href=$href&sort=ordnumber>|
307 . $locale->text('Order')
309 $column_header{quonumber} =
310 qq|<th><a class=listheading href=$href&sort=quonumber>|
311 . $locale->text('Quotation')
314 $label = ucfirst $form->{db} . "s";
315 $form->{title} = $locale->text($label);
324 <th class=listtop>$form->{title}</th>
333 <tr class=listheading>
336 map { print "$column_header{$_}\n" } @column_index;
342 $ordertype = ($form->{db} eq 'customer') ? 'sales_order' : 'purchase_order';
344 ($form->{db} eq 'customer') ? 'sales_quotation' : 'request_quotation';
346 foreach $ref (@{ $form->{CT} }) {
348 if ($ref->{id} eq $sameid) {
349 map { $column_data{$_} = "<td> </td>" } @column_index;
351 map { $column_data{$_} = "<td>$ref->{$_} </td>" } @column_index;
353 map { $column_data{$_} = "<td>$ref->{$_} </td>" }
354 (invnumber, ordnumber, quonumber);
357 "<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>";
360 $email = $ref->{email};
361 $email =~ s/</\</;
362 $email =~ s/>/\>/;
364 $column_data{email} =
365 qq|<td><a href="mailto:$ref->{email}">$email</a></td>|;
370 if ($ref->{formtype} eq 'invoice') {
371 $column_data{invnumber} =
372 "<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>";
375 if ($ref->{formtype} eq 'order') {
376 $column_data{ordnumber} =
377 "<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>";
380 if ($ref->{formtype} eq 'quotation') {
381 $column_data{quonumber} =
382 "<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>";
391 map { print "$column_data{$_}\n" } @column_index;
397 $sameid = $ref->{id};
406 <td><hr size=3 noshade></td>
411 <form method=post action=$form->{script}>
413 <input name=callback type=hidden value="$form->{callback}">
414 <input name=db type=hidden value=$form->{db}>
416 <input type=hidden name=path value=$form->{path}>
417 <input type=hidden name=login value=$form->{login}>
418 <input type=hidden name=password value=$form->{password}>
420 <input class=submit type=submit name=action value="|
421 . $locale->text('Add') . qq|">|;
423 if ($form->{menubar}) {
424 require "$form->{path}/menu.pl";
435 $lxdebug->leave_sub();
439 $lxdebug->enter_sub();
441 # $locale->text('Edit Customer')
442 # $locale->text('Edit Vendor')
444 CT->get_tuple(\%myconfig, \%$form);
446 # format " into "
447 map { $form->{$_} =~ s/\"/"/g } keys %$form;
449 $form->{title} = "Edit";
452 $form->{discount} *= 100;
457 $lxdebug->leave_sub();
461 $lxdebug->enter_sub();
463 $form->{taxincluded} = ($form->{taxincluded}) ? "checked" : "";
464 $form->{creditlimit} =
465 $form->format_amount(\%myconfig, $form->{creditlimit}, 0);
466 $form->{discount} = $form->format_amount(\%myconfig, $form->{discount});
468 if ($myconfig{role} eq 'admin') {
471 <th align=right nowrap>| . $locale->text('Bcc') . qq|</th>
472 <td><input name=bcc size=35 value="$form->{bcc}"></td>
476 $form->{obsolete} = "checked" if $form->{obsolete};
477 %langs = (de => "deutsch", en => "englisch", fr => "französisch");
478 $lang = qq|<option value=""></option>|;
479 foreach $item (keys %langs) {
480 if ($form->{language} eq $item) {
481 $lang .= qq|<option value="$item" selected>$langs{$item}</option>|;
483 $lang .= qq|<option value="$item">$langs{$item}</option>|;
487 foreach $item (split / /, $form->{taxaccounts}) {
488 if (($form->{tax}{$item}{taxable}) || !($form->{id})) {
490 qq| <input name="tax_$item" value=1 class=checkbox type=checkbox checked> <b>$form->{tax}{$item}{description}</b>|;
493 qq| <input name="tax_$item" value=1 class=checkbox type=checkbox> <b>$form->{tax}{$item}{description}</b>|;
503 <th align=right>| . $locale->text('Taxable') . qq|</th>
508 <td><input name=taxincluded class=checkbox type=checkbox value=1 $form->{taxincluded}></td>
509 <th align=left>| . $locale->text('Tax Included') . qq|</th>
516 $form->{selectbusiness} = qq|<option>\n|;
518 $form->{selectbusiness} .=
519 qq|<option value=$_->{id}>$_->{description}\n|
520 } @{ $form->{all_business} };
521 if ($form->{business_save}) {
522 $form->{selectbusiness} = $form->{business_save};
524 $form->{selectbusiness} =~
525 s/<option value=$form->{business}>/<option value=$form->{business} selected>/;
527 $label = ucfirst $form->{db};
528 $form->{title} = $locale->text("$form->{title} $label");
529 if ($form->{title_save}) {
530 $form->{title} = $form->{title_save};
532 if ($form->{db} eq 'vendor') {
534 <th align=right>| . $locale->text('Kundennummer') . qq|</th>
535 <td><input name=v_customer_id size=10 tabindex=18 maxlength=35 value="$form->{v_customer_id}"></td>
539 if ($form->{db} eq 'customer') {
542 <th align=right>| . $locale->text('KNr. beim Kunden') . qq|</th>
543 <td><input name=c_vendor_id size=10 tabindex=18 maxlength=35 value="$form->{c_vendor_id}"></td>
546 $business_salesman = "";
547 $business = "<th></th><td></td>";
549 $business_salesman = qq|
553 <th align=right>| . $locale->text('Type of Business') . qq|</th>
554 <td><select name=business tabindex=1>$form->{selectbusiness}</select></td>
555 <th align=right>| . $locale->text('Salesman') . qq|</th>
556 <td><input name=salesman tabindex=2 value="$form->{salesman}"></td>
557 <input type=hidden name=salesman_id value="$form->{salesman_id}">
558 <input type=hidden name=oldsalesman value="$form->{oldsalesman}">
563 <th align=right>| . $locale->text('Username') . qq|</th>
564 <td><input name=username maxlength=50 tabindex=22 value="$form->{username}"></td>
565 <th align=right>| . $locale->text('Password') . qq|</th>
566 <td><input name=user_password maxlength=12 tabindex=23 value="$form->{user_password}"></td>|;
569 <th align=right>| . $locale->text('Type of Business') . qq|</th>
570 <td><select name=business tabindex=22>$form->{selectbusiness}</select></td>
574 ## LINET: Create a drop-down box with all prior titles and greetings.
575 CT->query_titles_and_greetings(\%myconfig, \%$form);
577 $select_title = qq| <select name=selected_cp_title><option></option>|;
578 map({ $select_title .= qq|<option>$_</option>|; } @{ $form->{TITLES} });
579 $select_title .= qq|</select>|;
582 qq| <select name=selected_cp_greeting><option></option>|;
584 { $select_greeting .= qq|<option>$_</option>|; } @{ $form->{GREETINGS} });
585 $select_greeting .= qq|</select>|;
588 if ($form->{db} eq 'customer') {
590 #get pricegroup and form it
591 $form->get_pricegroup(\%myconfig, { all => 1 });
593 $form->{pricegroup} = "$form->{klass}";
594 $form->{pricegroup_id} = "$form->{klass}";
596 if (@{ $form->{all_pricegroup} }) {
598 $form->{selectpricegroup} = qq|<option>\n|;
600 $form->{selectpricegroup} .=
601 qq|<option value="$_->{id}">$_->{pricegroup}\n|
602 } @{ $form->{all_pricegroup} };
605 if ($form->{selectpricegroup}) {
606 $form->{selectpricegroup} = $form->unescape($form->{selectpricegroup});
609 qq|<input type=hidden name=selectpricegroup value="|
610 . $form->escape($form->{selectpricegroup}, 1) . qq|">|;
612 $form->{selectpricegroup} =~
613 s/(<option value="\Q$form->{klass}\E")/$1 selected/;
615 $pricegroup .= qq|<select name=klass>$form->{selectpricegroup}</select>|;
620 # $locale->text('Customer Number')
621 # $locale->text('Vendor Number')
622 $form->{fokus} = "ct.name";
626 <body onLoad="fokus()">
627 <form method=post name="ct" action=$form->{script}>
631 <th class=listtop>$form->{title}</th>
636 <tr class=listheading>
637 <th class=listheading colspan=2 width=50%>|
638 . $locale->text('Billing Address') . qq|</th>
639 <th class=listheading width=50%>|
640 . $locale->text('Shipping Address') . qq|</th>
645 <th align=right nowrap>| . $locale->text($label . ' Number') . qq|</th>
646 <td><input name="$form->{db}number" size=35 maxlength=35 value="$form->{"$form->{db}number"}"></td>
649 <th align=right nowrap>| . $locale->text('Company Name') . qq|</th>
650 <td><input name=name size=35 maxlength=75 tabindex=1 value="$form->{name}"></td>
651 <td><input name=shiptoname size=35 maxlength=75 value="$form->{shiptoname}"></td>
654 <th align=right nowrap>| . $locale->text('Abteilung') . qq|</th>
655 <td><input name=department_1 size=16 maxlength=75 tabindex=2 value="$form->{department_1}">
656 <input name=department_2 size=16 maxlength=75 tabindex=3 value="$form->{department_2}"></td>
657 <td><input name=shiptodepartment_1 size=16 maxlength=75 value="$form->{shiptodepartment_1}">
658 <input name=shiptodepartment_2 size=16 maxlength=75 value="$form->{shiptodepartment_2}"></td>
661 <th align=right nowrap>| . $locale->text('Street') . qq|</th>
662 <td><input name=street size=35 tabindex=4 maxlength=75 value="$form->{street}"></td>
663 <td><input name=shiptostreet size=35 maxlength=75 value="$form->{shiptostreet}"></td>
666 <th align=right nowrap>|
667 . $locale->text('Zipcode') . "/" . $locale->text('City') . qq|</th>
668 <td><input name=zipcode size=5 tabindex=5 maxlength=10 value="$form->{zipcode}">
669 <input name=city size=30 tabindex=6 maxlength=75 value="$form->{city}"></td>
670 <td><input name=shiptozipcode size=5 maxlength=10 value="$form->{shiptozipcode}">
671 <input name=shiptocity size=30 maxlength=75 value="$form->{shiptocity}"></td>
674 <th align=right nowrap>| . $locale->text('Country') . qq|</th>
675 <td><input name=country size=35 tabindex=7 maxlength=75 value="$form->{country}"></td>
676 <td><input name=shiptocountry size=35 maxlength=35 value="$form->{shiptocountry}"></td>
679 <th align=right nowrap>| . $locale->text('Contact') . qq|</th>
680 <td><input name=contact size=28 tabindex=8 maxlength=75 value="$form->{contact}"></td>
681 <td><input name=shiptocontact size=30 maxlength=75 value="$form->{shiptocontact}"></td>
684 <th align=right nowrap>| . $locale->text('Phone') . qq|</th>
685 <td><input name=phone size=30 tabindex=9 maxlength=30 value="$form->{phone}"></td>
686 <td><input name=shiptophone size=30 maxlength=30 value="$form->{shiptophone}"></td>
689 <th align=right nowrap>| . $locale->text('Fax') . qq|</th>
690 <td><input name=fax size=30 tabindex=10 maxlength=30 value="$form->{fax}"></td>
691 <td><input name=shiptofax size=30 maxlength=30 value="$form->{shiptofax}"></td>
694 <th align=right nowrap>| . $locale->text('E-mail') . qq|</th>
695 <td><input name=email tabindex=11 size=45 value="$form->{email}"></td>
696 <td><input name=shiptoemail size=45 value="$form->{shiptoemail}"></td>
699 <th align=right nowrap>| . $locale->text('Homepage') . qq|</th>
700 <td><input name=homepage tabindex=12 size=45 value="$form->{homepage}"></td>
704 ##LINET - added fields for contact person
707 <input type=hidden name=cp_id value=$form->{cp_id}>
710 <th align=right nowrap>|
711 . $locale->text('Contact Person') . qq|</th>
715 <th align=left nowrap>| . $locale->text('Greeting') . qq|</th>
716 <td><input name=cp_greeting size=30 maxlength=30 value="$form->{cp_greeting}">
717 $select_greeting</td>
718 <th align=left nowrap>| . $locale->text('Title') . qq|</th>
719 <td><input name=cp_title size=30 maxlength=30 value="$form->{cp_title}">
724 <th align=left nowrap>|
725 . $locale->text('Given Name') . qq|</th>
726 <td><input name=cp_givenname size=30 maxlength=40 value="$form->{cp_givenname}"></td>
727 <th align=left nowrap>| . $locale->text('Name') . qq|</th>
728 <td><input name=cp_name size=30 maxlength=40 value="$form->{cp_name}"></td>
732 <th align=left nowrap>| . $locale->text('Phone1') . qq|</th>
733 <td><input name=cp_phone1 size=30 maxlength=30 value="$form->{cp_phone1}"></td>
734 <th align=left nowrap>| . $locale->text('Phone2') . qq|</th>
735 <td><input name=cp_phone2 size=30 maxlength=30 value="$form->{cp_phone2}"></td>
739 <th align=left nowrap>| . $locale->text('E-mail') . qq|</th>
740 <td><input name=cp_email size=30 maxlength=40 value="$form->{cp_email}"></td>
746 <tr height="5"></tr>|;
757 <th align=right>| . $locale->text('Credit Limit') . qq|</th>
758 <td><input name=creditlimit tabindex=13 size=9 value="$form->{creditlimit}"></td>
759 <th align=right>| . $locale->text('Terms: Net') . qq|</th>
760 <td><input name=terms tabindex=14 size=2 value="$form->{terms}">|
761 . $locale->text('days') . qq|</td>
762 <th align=right>| . $locale->text('Discount') . qq|</th>
763 <td><input name=discount tabindex=15 size=4 value="$form->{discount}">
767 <th align=right>| . $locale->text('Tax Number / SSN') . qq|</th>
768 <td><input name=taxnumber tabindex=16 size=20 value="$form->{taxnumber}"></td>
769 <th align=right>| . $locale->text('USt-IdNr.') . qq|</th>
770 <td><input name=ustid tabindex=17 size=20 value="$form->{ustid}"></td>
774 <th align=right>| . $locale->text('Account Number') . qq|</th>
775 <td><input name=account_number size=10 tabindex=19 value="$form->{account_number}"></td>
776 <th align=right>| . $locale->text('Bank Code Number') . qq|</th>
777 <td><input name=bank_code size=10 tabindex=20 value="$form->{bank_code}"></td>
778 <th align=right>| . $locale->text('Bank') . qq|</th>
779 <td><input name=bank size=30 tabindex=21 value="$form->{bank}"></td>
783 <th align=right>| . $locale->text('Language') . qq|</th>
784 <td><select name=language tabindex=23>$lang
787 if ($form->{db} eq 'customer') {
790 <th align=right>| . $locale->text('Preisklasse') . qq|</th>
791 <td>$pricegroup</td>|;
795 <td align=right>| . $locale->text('Obsolete') . qq|</td>
796 <td><input name=obsolete class=checkbox type=checkbox value=1 $form->{obsolete}></td>
802 <th align=left nowrap>| . $locale->text('Notes') . qq|</th>
805 <td><textarea name=notes rows=3 cols=60 wrap=soft>$form->{notes}</textarea></td>
808 <td><hr size=3 noshade></td>
813 $lxdebug->leave_sub();
817 $lxdebug->enter_sub();
819 $label = ucfirst $form->{db};
821 ($form->{db} eq 'customer')
822 ? $locale->text('Save and Quotation')
823 : $locale->text('Save and RFQ');
825 ($form->{db} eq 'customer')
826 ? $locale->text('Save and AR Transaction')
827 : $locale->text('Save and AP Transaction');
830 qq|<input class=submit type=submit name=action accesskey="u" value="|
831 . $locale->text("Update") . qq|">|;
836 ##<input class=submit type=submit name=action value="|.$locale->text("Save and Quotation").qq|">
837 ##<input class=submit type=submit name=action value="|.$locale->text("Save and RFQ").qq|">
838 ##<input class=submit type=submit name=action value="|.$locale->text("Save and AR Transaction").qq|">
839 ##<input class=submit type=submit name=action value="|.$locale->text("Save and AP Transaction").qq|">
842 <input name=id type=hidden value=$form->{id}>
843 <input name=taxaccounts type=hidden value="$form->{taxaccounts}">
844 <input name=business_save type=hidden value="$form->{selectbusiness}">
845 <input name=title_save type=hidden value="$form->{title}">
847 <input type=hidden name=path value=$form->{path}>
848 <input type=hidden name=login value=$form->{login}>
849 <input type=hidden name=password value=$form->{password}>
851 <input type=hidden name=callback value="$form->{callback}">
852 <input type=hidden name=db value=$form->{db}>
858 <input class=submit type=submit name=action accesskey="s" value="|
859 . $locale->text("Save") . qq|">
860 <input class=submit type=submit name=action value="$arap">
861 <input class=submit type=submit name=action value="|
862 . $locale->text("Save and Invoice") . qq|">
863 <input class=submit type=submit name=action value="|
864 . $locale->text("Save and Order") . qq|">
865 <input class=submit type=submit name=action value="$quotation">
868 if ($form->{id} && $form->{status} eq 'orphaned') {
869 print qq|<input class=submit type=submit name=action value="|
870 . $locale->text('Delete')
874 if ($form->{menubar}) {
875 require "$form->{path}/menu.pl";
887 $lxdebug->leave_sub();
890 sub add_transaction {
891 $lxdebug->enter_sub();
893 $form->isblank("name", $locale->text("Name missing!"));
894 &{"CT::save_$form->{db}"}("", \%myconfig, \%$form);
896 $form->{callback} = $form->escape($form->{callback}, 1);
897 $name = $form->escape("$form->{name}", 1);
900 "$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}";
904 $lxdebug->leave_sub();
907 sub save_and_ap_transaction {
908 $lxdebug->enter_sub();
910 $form->{script} = "ap.pl";
913 $lxdebug->leave_sub();
916 sub save_and_ar_transaction {
917 $lxdebug->enter_sub();
919 $form->{script} = "ar.pl";
922 $lxdebug->leave_sub();
925 sub save_and_invoice {
926 $lxdebug->enter_sub();
928 $form->{script} = ($form->{db} eq 'customer') ? "is.pl" : "ir.pl";
929 $form->{type} = "invoice";
932 $lxdebug->leave_sub();
936 $lxdebug->enter_sub();
938 $form->{script} = "oe.pl";
939 $form->{type} = "request_quotation";
942 $lxdebug->leave_sub();
945 sub save_and_quotation {
946 $lxdebug->enter_sub();
948 $form->{script} = "oe.pl";
949 $form->{type} = "sales_quotation";
952 $lxdebug->leave_sub();
956 $lxdebug->enter_sub();
958 $form->{script} = "oe.pl";
960 ($form->{db} eq 'customer') ? "sales_order" : "purchase_order";
963 $lxdebug->leave_sub();
967 $lxdebug->enter_sub();
969 # $locale->text('Customer saved!')
970 # $locale->text('Vendor saved!')
972 $msg = ucfirst $form->{db};
975 $form->isblank("name", $locale->text("Name missing!"));
976 if ($vertreter && $form->{db} eq "customer") {
977 $form->isblank("salesman_id", $locale->text("Salesman missing!"));
979 $rc = &{"CT::save_$form->{db}"}("", \%myconfig, \%$form);
981 $form->error($locale->text('customernumber not unique!'));
983 $form->redirect($locale->text($msg));
985 $lxdebug->leave_sub();
989 $lxdebug->enter_sub();
991 # $locale->text('Customer deleted!')
992 # $locale->text('Cannot delete customer!')
993 # $locale->text('Vendor deleted!')
994 # $locale->text('Cannot delete vendor!')
996 CT->delete(\%myconfig, \%$form);
998 $msg = ucfirst $form->{db};
1000 $form->redirect($locale->text($msg));
1002 $msg = "Cannot delete $form->{db}";
1003 $form->error($locale->text($msg));
1005 $lxdebug->leave_sub();
1009 $lxdebug->enter_sub();
1014 $lxdebug->leave_sub();
1018 $lxdebug->enter_sub();
1020 &check_salesman($form->{salesman});
1022 # $form->get_salesman(\%myconfig, $form->{salesman});
1024 $lxdebug->leave_sub();
1027 sub check_salesman {
1028 $lxdebug->enter_sub();
1032 my ($new_name, $new_id) = split /--/, $form->{$name};
1035 # check name, combine name and id
1036 if ($form->{"oldsalesman"} ne $form->{"salesman"}) {
1038 # return one name or a list of names in $form->{name_list}
1039 if (($i = $form->get_salesman(\%myconfig, $name)) > 1) {
1040 &select_salesman($name);
1047 $form->{"salesman_id"} = $form->{salesman_list}[0]->{id};
1048 $form->{salesman} = $form->{salesman_list}[0]->{name};
1049 $form->{"oldsalesman"} = $form->{salesman};
1053 # name is not on file
1054 # $locale->text('Customer not on file!')
1055 # $locale->text('Vendor not on file!')
1056 $msg = ucfirst $name . " not on file or locked!";
1057 $form->error($locale->text($msg));
1061 $lxdebug->leave_sub();
1066 sub select_salesman {
1067 $lxdebug->enter_sub();
1071 @column_index = qw(ndx name);
1073 $label = ucfirst $table;
1074 $column_data{ndx} = qq|<th> </th>|;
1075 $column_data{name} =
1076 qq|<th class=listheading>| . $locale->text($label) . qq|</th>|;
1078 # list items with radio button on a form
1081 $title = $locale->text('Select from one of the names below');
1086 <form method=post action=$form->{script}>
1090 <th class=listtop>$title</th>
1096 <tr class=listheading>|;
1098 map { print "\n$column_data{$_}" } @column_index;
1105 foreach $ref (@{ $form->{salesman_list} }) {
1106 $checked = ($i++) ? "" : "checked";
1108 $ref->{name} =~ s/\"/"/g;
1111 qq|<td><input name=ndx class=radio type=radio value=$i $checked></td>|;
1112 $column_data{name} =
1113 qq|<td><input name="new_name_$i" type=hidden value="$ref->{name}">$ref->{name}</td>|;
1118 <tr class=listrow$j>|;
1120 map { print "\n$column_data{$_}" } @column_index;
1125 <input name="new_id_$i" type=hidden value=$ref->{id}>
1136 <td><hr size=3 noshade></td>
1140 <input name=lastndx type=hidden value=$i>
1145 map { delete $form->{$_} } qw(action name_list header);
1147 # save all other form variables
1148 foreach $key (keys %${form}) {
1149 $form->{$key} =~ s/\"/"/g;
1150 print qq|<input name=$key type=hidden value="$form->{$key}">\n|;
1154 <input type=hidden name=nextsub value=salesman_selected>
1156 <input type=hidden name=vc value=$table>
1158 <input class=submit type=submit name=action value="|
1159 . $locale->text('Continue') . qq|">
1166 $lxdebug->leave_sub();
1169 sub salesman_selected {
1170 $lxdebug->enter_sub();
1172 # replace the variable with the one checked
1174 # index for new item
1177 $form->{salesman} = $form->{"new_name_$i"};
1178 $form->{"salesman_id"} = $form->{"new_id_$i"};
1179 $form->{"oldsalesman"} = $form->{salesman};
1181 # delete all the new_ variables
1182 for $i (1 .. $form->{lastndx}) {
1183 map { delete $form->{"new_${_}_$i"} } (id, name);
1186 map { delete $form->{$_} } qw(ndx lastndx nextsub);
1190 $lxdebug->leave_sub();
1193 sub continue { &{ $form->{nextsub} } }