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')
48 $lxdebug->enter_sub();
51 $form->{title} = "Add";
53 $form->{callback} = "$form->{script}?action=add&db=$form->{db}&path=$form->{path}&login=$form->{login}&password=$form->{password}" unless $form->{callback};
55 CT->taxaccounts(\%myconfig, \%$form);
60 $lxdebug->leave_sub();
65 $lxdebug->enter_sub();
68 $label = ucfirst $form->{db};
69 $form->{title} = $locale->text($label."s");
71 if ($form->{db} eq 'vendor') {
73 <td><input name="l_gifi_accno" type=checkbox class=checkbox value=Y> |.$locale->text('GIFI').qq|</td>
82 <form method=post action=$form->{script}>
84 <input type=hidden name=db value=$form->{db}>
88 <th class=listtop>$form->{title}</th>
95 <th align=right nowrap>|.$locale->text($label . ' Number').qq|</th>
96 <td><input name=$form->{db}number size=35></td>
99 <th align=right nowrap>|.$locale->text('Company Name').qq|</th>
100 <td><input name=name size=35></td>
103 <th align=right nowrap>|.$locale->text('Contact').qq|</th>
104 <td><input name=contact size=35></td>
107 <th align=right nowrap>|.$locale->text('E-mail').qq|</th>
108 <td><input name=email size=35></td>
112 <td><input name=status class=radio type=radio value=all checked> |.$locale->text('All').qq|
113 <input name=status class=radio type=radio value=orphaned> |.$locale->text('Orphaned').qq|</td>
116 <th align=right nowrap>|.$locale->text('Include in Report').qq|</th>
120 <td><input name="l_id" type=checkbox class=checkbox value=Y> |.$locale->text('ID').qq|</td>
121 <td><input name="l_$form->{db}number" type=checkbox class=checkbox value=Y> |.$locale->text($label . ' Number').qq|</td>
122 <td><input name="l_name" type=checkbox class=checkbox value=Y checked> |.$locale->text('Company Name').qq|</td>
123 <td><input name="l_address" type=checkbox class=checkbox value=Y> |.$locale->text('Address').qq|</td>
126 <td><input name="l_contact" type=checkbox class=checkbox value=Y checked> |.$locale->text('Contact').qq|</td>
127 <td><input name="l_phone" type=checkbox class=checkbox value=Y checked> |.$locale->text('Phone').qq|</td>
128 <td><input name="l_fax" type=checkbox class=checkbox value=Y> |.$locale->text('Fax').qq|</td>
129 <td><input name="l_email" type=checkbox class=checkbox value=Y checked> |.$locale->text('E-mail').qq|</td>
132 <td><input name="l_taxnumber" type=checkbox class=checkbox value=Y> |.$locale->text('Tax Number').qq|</td>
134 <td><input name="l_sic_code" type=checkbox class=checkbox value=Y> |.$locale->text('SIC').qq|</td>
135 <td><input name="l_business" type=checkbox class=checkbox value=Y> |.$locale->text('Type of Business').qq|</td>
138 <td><input name="l_invnumber" type=checkbox class=checkbox value=Y> |.$locale->text('Invoices').qq|</td>
139 <td><input name="l_ordnumber" type=checkbox class=checkbox value=Y> |.$locale->text('Orders').qq|</td>
140 <td><input name="l_quonumber" type=checkbox class=checkbox value=Y> |.$locale->text('Quotations').qq|</td>
149 <td><hr size=3 noshade></td>
153 <input type=hidden name=nextsub value=list_names>
155 <input type=hidden name=path value=$form->{path}>
156 <input type=hidden name=login value=$form->{login}>
157 <input type=hidden name=password value=$form->{password}>
160 <input type=submit class=submit name=action value="|.$locale->text('Continue').qq|">
166 $lxdebug->leave_sub();
171 $lxdebug->enter_sub();
173 CT->search(\%myconfig, \%$form);
175 $callback = "$form->{script}?action=list_names&db=$form->{db}&path=$form->{path}&login=$form->{login}&password=$form->{password}&status=$form->{status}";
178 @columns = $form->sort_columns(id, name, "$form->{db}number", address, contact, phone, fax, email, taxnumber, gifi_accno, sic_code, business, invnumber, ordnumber, quonumber);
180 foreach $item (@columns) {
181 if ($form->{"l_$item"} eq "Y") {
182 push @column_index, $item;
184 # add column to href and callback
185 $callback .= "&l_$item=Y";
186 $href .= "&l_$item=Y";
189 $number = ($form->{db} eq "customer") ? $locale->text('Customer Number') : $locale->text('Vendor Number') ;
191 if ($form->{status} eq 'all') {
192 $option = $locale->text('All');
194 if ($form->{status} eq 'orphaned') {
195 $option .= $locale->text('Orphaned');
198 $callback .= "&name=".$form->escape($form->{name},1);
199 $href .= "&name=".$form->escape($form->{name});
200 $option .= "\n<br>".$locale->text('Name')." : $form->{name}";
202 if ($form->{contact}) {
203 $callback .= "&contact=".$form->escape($form->{contact},1);
204 $href .= "&contact=".$form->escape($form->{contact});
205 $option .= "\n<br>".$locale->text('Contact')." : $form->{contact}";
207 if ($form->{"$form->{db}number"}) {
208 $callback .= qq|&$form->{db}number=|.$form->escape($form->{"$form->{db}number"},1);
209 $href .= "&$form->{db}number=".$form->escape($form->{"$form->{db}number"});
210 $option .= "\n<br>".$locale->text('Number').qq| : $form->{"$form->{db}number"}|;
212 if ($form->{email}) {
213 $callback .= "&email=".$form->escape($form->{email},1);
214 $href .= "&email=".$form->escape($form->{email});
215 $option .= "\n<br>".$locale->text('E-mail')." : $form->{email}";
218 $form->{callback} = "$callback&sort=$form->{sort}";
219 $callback = $form->escape($form->{callback});
221 $column_header{id} = qq|<th class=listheading>|.$locale->text('ID').qq|</th>|;
222 $column_header{"$form->{db}number"} = qq|<th><a class=listheading href=$href&sort=$form->{db}number>$number</a></th>|;
223 $column_header{name} = qq|<th><a class=listheading href=$href&sort=name>|.$locale->text('Name').qq|</a></th>|;
224 $column_header{address} = qq|<th><a class=listheading href=$href&sort=address>|.$locale->text('Address').qq|</a></th>|;
225 $column_header{contact} = qq|<th><a class=listheading href=$href&sort=contact>|.$locale->text('Contact').qq|</a></th>|;
226 $column_header{phone} = qq|<th><a class=listheading href=$href&sort=phone>|.$locale->text('Phone').qq|</a></th>|;
227 $column_header{fax} = qq|<th><a class=listheading href=$href&sort=fax>|.$locale->text('Fax').qq|</a></th>|;
228 $column_header{email} = qq|<th><a class=listheading href=$href&sort=email>|.$locale->text('E-mail').qq|</a></th>|;
229 $column_header{cc} = qq|<th><a class=listheading href=$href&sort=cc>|.$locale->text('Cc').qq|</a></th>|;
231 $column_header{taxnumber} = qq|<th><a class=listheading href=$href&sort=taxnumber>|.$locale->text('Tax Number').qq|</a></th>|;
232 $column_header{gifi_accno} = qq|<th><a class=listheading href=$href&sort=gifi_accno>|.$locale->text('GIFI').qq|</a></th>|;
233 $column_header{sic_code} = qq|<th><a class=listheading href=$href&sort=sic_code>|.$locale->text('SIC').qq|</a></th>|;
234 $column_header{business} = qq|<th><a class=listheading href=$href&sort=business>|.$locale->text('Type of Business').qq|</a></th>|;
236 $column_header{invnumber} = qq|<th><a class=listheading href=$href&sort=invnumber>|.$locale->text('Invoice').qq|</a></th>|;
237 $column_header{ordnumber} = qq|<th><a class=listheading href=$href&sort=ordnumber>|.$locale->text('Order').qq|</a></th>|;
238 $column_header{quonumber} = qq|<th><a class=listheading href=$href&sort=quonumber>|.$locale->text('Quotation').qq|</a></th>|;
241 $label = ucfirst $form->{db}."s";
242 $form->{title} = $locale->text($label);
251 <th class=listtop>$form->{title}</th>
260 <tr class=listheading>
263 map { print "$column_header{$_}\n" } @column_index;
269 $ordertype = ($form->{db} eq 'customer') ? 'sales_order' : 'purchase_order';
270 $quotationtype = ($form->{db} eq 'customer') ? 'sales_quotation' : 'request_quotation';
272 foreach $ref (@{ $form->{CT} }) {
274 if ($ref->{id} eq $sameid) {
275 map { $column_data{$_} = "<td> </td>" } @column_index;
277 map { $column_data{$_} = "<td>$ref->{$_} </td>" } @column_index;
279 map { $column_data{$_} = "<td>$ref->{$_} </td>" } (invnumber, ordnumber, quonumber);
281 $column_data{name} = "<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>";
284 $email = $ref->{email};
285 $email =~ s/</\</;
286 $email =~ s/>/\>/;
288 $column_data{email} = qq|<td><a href="mailto:$ref->{email}">$email</a></td>|;
294 if ($ref->{formtype} eq 'invoice') {
295 $column_data{invnumber} = "<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>";
298 if ($ref->{formtype} eq 'order') {
299 $column_data{ordnumber} = "<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>";
302 if ($ref->{formtype} eq 'quotation') {
303 $column_data{quonumber} = "<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>";
312 map { print "$column_data{$_}\n" } @column_index;
318 $sameid = $ref->{id};
327 <td><hr size=3 noshade></td>
332 <form method=post action=$form->{script}>
334 <input name=callback type=hidden value="$form->{callback}">
335 <input name=db type=hidden value=$form->{db}>
337 <input type=hidden name=path value=$form->{path}>
338 <input type=hidden name=login value=$form->{login}>
339 <input type=hidden name=password value=$form->{password}>
341 <input class=submit type=submit name=action value="|.$locale->text('Add').qq|">|;
343 if ($form->{menubar}) {
344 require "$form->{path}/menu.pl";
355 $lxdebug->leave_sub();
360 $lxdebug->enter_sub();
363 # $locale->text('Edit Customer')
364 # $locale->text('Edit Vendor')
366 CT->get_tuple(\%myconfig, \%$form);
368 # format " into "
369 map { $form->{$_} =~ s/\"/"/g } keys %$form;
371 $form->{title} = "Edit";
374 $form->{discount} *= 100;
379 $lxdebug->leave_sub();
384 $lxdebug->enter_sub();
387 $form->{taxincluded} = ($form->{taxincluded}) ? "checked" : "";
388 $form->{creditlimit} = $form->format_amount(\%myconfig, $form->{creditlimit}, 0);
390 if ($myconfig{role} eq 'admin') {
393 <th align=right nowrap>|.$locale->text('Bcc').qq|</th>
394 <td><input name=bcc size=35 value="$form->{bcc}"></td>
398 $form->{obsolete} = "checked" if $form->{obsolete};
399 %langs = (de=>"deutsch", en=>"englisch", fr=>"französisch");
400 $lang = qq|<option value=""></option>|;
401 foreach $item (keys %langs) {
402 if ($form->{language} eq $item) {
403 $lang .= qq|<option value="$item" selected>$langs{$item}</option>|;
405 $lang .= qq|<option value="$item">$langs{$item}</option>|;
409 foreach $item (split / /, $form->{taxaccounts}) {
410 if (($form->{tax}{$item}{taxable}) || !($form->{id})) {
411 $taxable .= qq| <input name="tax_$item" value=1 class=checkbox type=checkbox checked> <b>$form->{tax}{$item}{description}</b>|;
413 $taxable .= qq| <input name="tax_$item" value=1 class=checkbox type=checkbox> <b>$form->{tax}{$item}{description}</b>|;
423 <th align=right>|.$locale->text('Taxable').qq|</th>
428 <td><input name=taxincluded class=checkbox type=checkbox value=1 $form->{taxincluded}></td>
429 <th align=left>|.$locale->text('Tax Included').qq|</th>
437 $form->{selectbusiness} = qq|<option>\n|;
438 map { $form->{selectbusiness} .= qq|<option value=$_->{id}>$_->{description}\n| } @{ $form->{all_business} };
439 if ($form->{business_save}) {
440 $form->{selectbusiness} = $form->{business_save};
442 $form->{selectbusiness} =~ s/<option value=$form->{business}>/<option value=$form->{business} selected>/;
444 $label = ucfirst $form->{db};
445 $form->{title} = $locale->text("$form->{title} $label");
446 if ($form->{title_save}) {
447 $form->{title} = $form->{title_save};
449 if ($form->{db} eq 'vendor') {
451 <th align=right>|.$locale->text('Kundennummer').qq|</th>
452 <td><input name=v_customer_id size=10 tabindex=18 maxlength=35 value="$form->{v_customer_id}"></td>
456 if ($form->{db} eq 'customer') {
459 <th align=right>|.$locale->text('KNr. beim Kunden').qq|</th>
460 <td><input name=c_vendor_id size=10 tabindex=18 maxlength=35 value="$form->{c_vendor_id}"></td>
463 $business_salesman = "";
464 $business = "<th></th><td></td>";
466 $business_salesman = qq|
470 <th align=right>|.$locale->text('Type of Business').qq|</th>
471 <td><select name=business tabindex=1>$form->{selectbusiness}</select></td>
472 <th align=right>|.$locale->text('Salesman').qq|</th>
473 <td><input name=salesman tabindex=2 value="$form->{salesman}"></td>
474 <input type=hidden name=salesman_id value="$form->{salesman_id}">
475 <input type=hidden name=oldsalesman value="$form->{oldsalesman}">
480 <th align=right>|.$locale->text('Username').qq|</th>
481 <td><input name=username maxlength=50 tabindex=22 value="$form->{username}"></td>
482 <th align=right>|.$locale->text('Password').qq|</th>
483 <td><input name=user_password maxlength=12 tabindex=23 value="$form->{user_password}"></td>|;
486 <th align=right>|.$locale->text('Type of Business').qq|</th>
487 <td><select name=business tabindex=22>$form->{selectbusiness}</select></td>
491 ## LINET: Create a drop-down box with all prior titles and greetings.
492 CT->query_titles_and_greetings(\%myconfig, \%$form);
494 $select_title = qq| <select name=selected_cp_title><option></option>|;
495 map({ $select_title .= qq|<option>$_</option>|; } @{$form->{TITLES}});
496 $select_title .= qq|</select>|;
498 $select_greeting = qq| <select name=selected_cp_greeting><option></option>|;
499 map({ $select_greeting .= qq|<option>$_</option>|; } @{$form->{GREETINGS}});
500 $select_greeting .= qq|</select>|;
503 # $locale->text('Customer Number')
504 # $locale->text('Vendor Number')
505 $form->{fokus} = "ct.name";
509 <body onLoad="fokus()">
510 <form method=post name="ct" action=$form->{script}>
514 <th class=listtop>$form->{title}</th>
519 <tr class=listheading>
520 <th class=listheading colspan=2 width=50%>|.$locale->text('Billing Address').qq|</th>
521 <th class=listheading width=50%>|.$locale->text('Shipping Address').qq|</th>
526 <th align=right nowrap>|.$locale->text($label .' Number').qq|</th>
527 <td><input name="$form->{db}number" size=35 maxlength=35 value="$form->{"$form->{db}number"}"></td>
530 <th align=right nowrap>|.$locale->text('Company Name').qq|</th>
531 <td><input name=name size=35 maxlength=35 tabindex=1 value="$form->{name}"></td>
532 <td><input name=shiptoname size=35 maxlength=75 value="$form->{shiptoname}"></td>
535 <th align=right nowrap>|.$locale->text('Abteilung').qq|</th>
536 <td><input name=department_1 size=16 maxlength=75 tabindex=2 value="$form->{department_1}">
537 <input name=department_2 size=16 maxlength=75 tabindex=3 value="$form->{department_2}"></td>
538 <td><input name=shiptodepartment_1 size=16 maxlength=75 value="$form->{shiptodepartment_1}">
539 <input name=shiptodepartment_2 size=16 maxlength=75 value="$form->{shiptodepartment_2}"></td>
542 <th align=right nowrap>|.$locale->text('Street').qq|</th>
543 <td><input name=street size=35 tabindex=4 maxlength=75 value="$form->{street}"></td>
544 <td><input name=shiptostreet size=35 maxlength=35 value="$form->{shiptostreet}"></td>
547 <th align=right nowrap>|.$locale->text('Zipcode')."/".$locale->text('City').qq|</th>
548 <td><input name=zipcode size=5 tabindex=5 maxlength=10 value="$form->{zipcode}">
549 <input name=city size=30 tabindex=6 maxlength=75 value="$form->{city}"></td>
550 <td><input name=shiptozipcode size=5 maxlength=10 value="$form->{shiptozipcode}">
551 <input name=shiptocity size=30 maxlength=75 value="$form->{shiptocity}"></td>
554 <th align=right nowrap>|.$locale->text('Country').qq|</th>
555 <td><input name=country size=35 tabindex=7 maxlength=75 value="$form->{country}"></td>
556 <td><input name=shiptocountry size=35 maxlength=35 value="$form->{shiptocountry}"></td>
559 <th align=right nowrap>|.$locale->text('Contact').qq|</th>
560 <td><input name=contact size=28 tabindex=8 maxlength=75 value="$form->{contact}"></td>
561 <td><input name=shiptocontact size=30 maxlength=75 value="$form->{shiptocontact}"></td>
564 <th align=right nowrap>|.$locale->text('Phone').qq|</th>
565 <td><input name=phone size=30 tabindex=9 maxlength=30 value="$form->{phone}"></td>
566 <td><input name=shiptophone size=30 maxlength=30 value="$form->{shiptophone}"></td>
569 <th align=right nowrap>|.$locale->text('Fax').qq|</th>
570 <td><input name=fax size=30 tabindex=10 maxlength=30 value="$form->{fax}"></td>
571 <td><input name=shiptofax size=30 maxlength=30 value="$form->{shiptofax}"></td>
574 <th align=right nowrap>|.$locale->text('E-mail').qq|</th>
575 <td><input name=email tabindex=11 size=45 value="$form->{email}"></td>
576 <td><input name=shiptoemail size=45 value="$form->{shiptoemail}"></td>
579 <th align=right nowrap>|.$locale->text('Homepage').qq|</th>
580 <td><input name=homepage tabindex=12 size=45 value="$form->{homepage}"></td>
584 ##LINET - added fields for contact person
587 <input type=hidden name=cp_id value=$form->{cp_id}>
590 <th align=right nowrap>|.$locale->text('Contact Person').qq|</th>
594 <th align=left nowrap>|.$locale->text('Greeting').qq|</th>
595 <td><input name=cp_greeting size=30 maxlength=30 value="$form->{cp_greeting}">
596 $select_greeting</td>
597 <th align=left nowrap>|.$locale->text('Title').qq|</th>
598 <td><input name=cp_title size=30 maxlength=30 value="$form->{cp_title}">
603 <th align=left nowrap>|.$locale->text('Given Name').qq|</th>
604 <td><input name=cp_givenname size=30 maxlength=40 value="$form->{cp_givenname}"></td>
605 <th align=left nowrap>|.$locale->text('Name').qq|</th>
606 <td><input name=cp_name size=30 maxlength=40 value="$form->{cp_name}"></td>
610 <th align=left nowrap>|.$locale->text('Phone1').qq|</th>
611 <td><input name=cp_phone1 size=30 maxlength=30 value="$form->{cp_phone1}"></td>
612 <th align=left nowrap>|.$locale->text('Phone2').qq|</th>
613 <td><input name=cp_phone2 size=30 maxlength=30 value="$form->{cp_phone2}"></td>
617 <th align=left nowrap>|.$locale->text('E-mail').qq|</th>
618 <td><input name=cp_email size=30 maxlength=40 value="$form->{cp_email}"></td>
624 <tr height="5"></tr>|;
635 <th align=right>|.$locale->text('Credit Limit').qq|</th>
636 <td><input name=creditlimit tabindex=13 size=9 value="$form->{creditlimit}"></td>
637 <th align=right>|.$locale->text('Terms: Net').qq|</th>
638 <td><input name=terms tabindex=14 size=2 value="$form->{terms}">|.$locale->text('days').qq|</td>
639 <th align=right>|.$locale->text('Discount').qq|</th>
640 <td><input name=discount tabindex=15 size=4 value="$form->{discount}">
644 <th align=right>|.$locale->text('Tax Number / SSN').qq|</th>
645 <td><input name=taxnumber tabindex=16 size=20 value="$form->{taxnumber}"></td>
646 <th align=right>|.$locale->text('USt-IdNr.').qq|</th>
647 <td><input name=ustid tabindex=17 size=20 value="$form->{ustid}"></td>
651 <th align=right>|.$locale->text('Account Number').qq|</th>
652 <td><input name=account_number size=10 tabindex=19 value="$form->{account_number}"></td>
653 <th align=right>|.$locale->text('Bank Code Number').qq|</th>
654 <td><input name=bank_code size=10 tabindex=20 value="$form->{bank_code}"></td>
655 <th align=right>|.$locale->text('Bank').qq|</th>
656 <td><input name=bank size=30 tabindex=21 value="$form->{bank}"></td>
660 <th align=right>|.$locale->text('Language').qq|</th>
661 <td><select name=language tabindex=23>$lang
666 <td align=right>|.$locale->text('Obsolete').qq|</td>
667 <td><input name=obsolete class=checkbox type=checkbox value=1 $form->{obsolete}></td>
673 <th align=left nowrap>|.$locale->text('Notes').qq|</th>
676 <td><textarea name=notes rows=3 cols=60 wrap=soft>$form->{notes}</textarea></td>
679 <td><hr size=3 noshade></td>
684 $lxdebug->leave_sub();
690 $lxdebug->enter_sub();
693 $label = ucfirst $form->{db};
694 $quotation = ($form->{db} eq 'customer') ? $locale->text('Save and Quotation') : $locale->text('Save and RFQ');
695 $arap = ($form->{db} eq 'customer') ? $locale->text('Save and AR Transaction') : $locale->text('Save and AP Transaction');
697 $update_button = qq|<input class=submit type=submit name=action accesskey="u" value="|.$locale->text("Update").qq|">|;
702 ##<input class=submit type=submit name=action value="|.$locale->text("Save and Quotation").qq|">
703 ##<input class=submit type=submit name=action value="|.$locale->text("Save and RFQ").qq|">
704 ##<input class=submit type=submit name=action value="|.$locale->text("Save and AR Transaction").qq|">
705 ##<input class=submit type=submit name=action value="|.$locale->text("Save and AP Transaction").qq|">
708 <input name=id type=hidden value=$form->{id}>
709 <input name=taxaccounts type=hidden value="$form->{taxaccounts}">
710 <input name=business_save type=hidden value="$form->{selectbusiness}">
711 <input name=title_save type=hidden value="$form->{title}">
713 <input type=hidden name=path value=$form->{path}>
714 <input type=hidden name=login value=$form->{login}>
715 <input type=hidden name=password value=$form->{password}>
717 <input type=hidden name=callback value="$form->{callback}">
718 <input type=hidden name=db value=$form->{db}>
722 <input class=submit type=submit name=action accesskey="s" value="|.$locale->text("Save").qq|">
723 <input class=submit type=submit name=action value="$arap">
724 <input class=submit type=submit name=action value="|.$locale->text("Save and Invoice").qq|">
725 <input class=submit type=submit name=action value="|.$locale->text("Save and Order").qq|">
726 <input class=submit type=submit name=action value="$quotation">
729 if ($form->{id} && $form->{status} eq 'orphaned') {
730 print qq|<input class=submit type=submit name=action value="|.$locale->text('Delete').qq|">\n|;
733 if ($form->{menubar}) {
734 require "$form->{path}/menu.pl";
746 $lxdebug->leave_sub();
750 sub add_transaction {
751 $lxdebug->enter_sub();
754 $form->isblank("name", $locale->text("Name missing!"));
755 &{ "CT::save_$form->{db}" }("", \%myconfig, \%$form);
757 $form->{callback} = $form->escape($form->{callback},1);
758 $name = $form->escape("$form->{name}",1);
760 $form->{callback} = "$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}";
764 $lxdebug->leave_sub();
767 sub save_and_ap_transaction {
768 $lxdebug->enter_sub();
771 $form->{script} = "ap.pl";
774 $lxdebug->leave_sub();
778 sub save_and_ar_transaction {
779 $lxdebug->enter_sub();
782 $form->{script} = "ar.pl";
785 $lxdebug->leave_sub();
789 sub save_and_invoice {
790 $lxdebug->enter_sub();
793 $form->{script} = ($form->{db} eq 'customer') ? "is.pl" : "ir.pl";
794 $form->{type} = "invoice";
797 $lxdebug->leave_sub();
802 $lxdebug->enter_sub();
805 $form->{script} = "oe.pl";
806 $form->{type} = "request_quotation";
809 $lxdebug->leave_sub();
813 sub save_and_quotation {
814 $lxdebug->enter_sub();
817 $form->{script} = "oe.pl";
818 $form->{type} = "sales_quotation";
821 $lxdebug->leave_sub();
826 $lxdebug->enter_sub();
829 $form->{script} = "oe.pl";
830 $form->{type} = ($form->{db} eq 'customer') ? "sales_order" : "purchase_order";
833 $lxdebug->leave_sub();
838 $lxdebug->enter_sub();
841 # $locale->text('Customer saved!')
842 # $locale->text('Vendor saved!')
844 $msg = ucfirst $form->{db};
847 $form->isblank("name", $locale->text("Name missing!"));
848 if ($vertreter && $form->{db} eq "customer") {
849 $form->isblank("salesman_id", $locale->text("Salesman missing!"));
851 &{ "CT::save_$form->{db}" }("", \%myconfig, \%$form);
853 $form->redirect($locale->text($msg));
855 $lxdebug->leave_sub();
860 $lxdebug->enter_sub();
863 # $locale->text('Customer deleted!')
864 # $locale->text('Cannot delete customer!')
865 # $locale->text('Vendor deleted!')
866 # $locale->text('Cannot delete vendor!')
868 CT->delete(\%myconfig, \%$form);
870 $msg = ucfirst $form->{db};
872 $form->redirect($locale->text($msg));
874 $msg = "Cannot delete $form->{db}";
875 $form->error($locale->text($msg));
877 $lxdebug->leave_sub();
881 $lxdebug->enter_sub();
886 $lxdebug->leave_sub();
890 $lxdebug->enter_sub();
892 &check_salesman($form->{salesman});
893 # $form->get_salesman(\%myconfig, $form->{salesman});
895 $lxdebug->leave_sub();
899 $lxdebug->enter_sub();
903 my ($new_name, $new_id) = split /--/, $form->{$name};
906 # check name, combine name and id
907 if ($form->{"oldsalesman"} ne$ form->{"salesman"} ) {
909 # return one name or a list of names in $form->{name_list}
910 if (($i = $form->get_salesman(\%myconfig, $name)) > 1) {
911 &select_salesman($name);
917 $form->{"salesman_id"} = $form->{salesman_list}[0]->{id};
918 $form->{salesman} = $form->{salesman_list}[0]->{name};
919 $form->{"oldsalesman"} = $form->{salesman};
922 # name is not on file
923 # $locale->text('Customer not on file!')
924 # $locale->text('Vendor not on file!')
925 $msg = ucfirst $name . " not on file or locked!";
926 $form->error($locale->text($msg));
931 $lxdebug->leave_sub();
939 sub select_salesman {
940 $lxdebug->enter_sub();
944 @column_index = qw(ndx name);
946 $label = ucfirst $table;
947 $column_data{ndx} = qq|<th> </th>|;
948 $column_data{name} = qq|<th class=listheading>|.$locale->text($label).qq|</th>|;
950 # list items with radio button on a form
953 $title = $locale->text('Select from one of the names below');
958 <form method=post action=$form->{script}>
962 <th class=listtop>$title</th>
968 <tr class=listheading>|;
970 map { print "\n$column_data{$_}" } @column_index;
977 foreach $ref (@{ $form->{salesman_list} }) {
978 $checked = ($i++) ? "" : "checked";
980 $ref->{name} =~ s/\"/"/g;
982 $column_data{ndx} = qq|<td><input name=ndx class=radio type=radio value=$i $checked></td>|;
983 $column_data{name} = qq|<td><input name="new_name_$i" type=hidden value="$ref->{name}">$ref->{name}</td>|;
987 <tr class=listrow$j>|;
989 map { print "\n$column_data{$_}" } @column_index;
994 <input name="new_id_$i" type=hidden value=$ref->{id}>
1005 <td><hr size=3 noshade></td>
1009 <input name=lastndx type=hidden value=$i>
1014 map { delete $form->{$_} } qw(action name_list header);
1016 # save all other form variables
1017 foreach $key (keys %${form}) {
1018 $form->{$key} =~ s/\"/"/g;
1019 print qq|<input name=$key type=hidden value="$form->{$key}">\n|;
1023 <input type=hidden name=nextsub value=salesman_selected>
1025 <input type=hidden name=vc value=$table>
1027 <input class=submit type=submit name=action value="|.$locale->text('Continue').qq|">
1034 $lxdebug->leave_sub();
1039 sub salesman_selected {
1040 $lxdebug->enter_sub();
1043 # replace the variable with the one checked
1045 # index for new item
1048 $form->{salesman} = $form->{"new_name_$i"};
1049 $form->{"salesman_id"} = $form->{"new_id_$i"};
1050 $form->{"oldsalesman"} = $form->{salesman};
1052 # delete all the new_ variables
1053 for $i (1 .. $form->{lastndx}) {
1054 map { delete $form->{"new_${_}_$i"} } (id, name);
1057 map { delete $form->{$_} } qw(ndx lastndx nextsub);
1061 $lxdebug->leave_sub();
1064 sub continue { &{ $form->{nextsub} } };