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')
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> |
113 . $locale->text('All') . qq|
114 <input name=status class=radio type=radio value=orphaned> |
115 . $locale->text('Orphaned')
119 <th align=right nowrap>| . $locale->text('Include in Report') . qq|</th>
123 <td><input name="l_id" type=checkbox class=checkbox value=Y> |
124 . $locale->text('ID')
126 <td><input name="l_$form->{db}number" type=checkbox class=checkbox value=Y> |
127 . $locale->text($label . ' Number')
129 <td><input name="l_name" type=checkbox class=checkbox value=Y checked> |
130 . $locale->text('Company Name')
132 <td><input name="l_address" type=checkbox class=checkbox value=Y> |
133 . $locale->text('Address')
137 <td><input name="l_contact" type=checkbox class=checkbox value=Y checked> |
138 . $locale->text('Contact')
140 <td><input name="l_phone" type=checkbox class=checkbox value=Y checked> |
141 . $locale->text('Phone')
143 <td><input name="l_fax" type=checkbox class=checkbox value=Y> |
144 . $locale->text('Fax')
146 <td><input name="l_email" type=checkbox class=checkbox value=Y checked> |
147 . $locale->text('E-mail')
151 <td><input name="l_taxnumber" type=checkbox class=checkbox value=Y> |
152 . $locale->text('Tax Number')
155 <td><input name="l_sic_code" type=checkbox class=checkbox value=Y> |
156 . $locale->text('SIC')
158 <td><input name="l_business" type=checkbox class=checkbox value=Y> |
159 . $locale->text('Type of Business')
163 <td><input name="l_invnumber" type=checkbox class=checkbox value=Y> |
164 . $locale->text('Invoices')
166 <td><input name="l_ordnumber" type=checkbox class=checkbox value=Y> |
167 . $locale->text('Orders')
169 <td><input name="l_quonumber" type=checkbox class=checkbox value=Y> |
170 . $locale->text('Quotations')
180 <td><hr size=3 noshade></td>
184 <input type=hidden name=nextsub value=list_names>
186 <input type=hidden name=path value=$form->{path}>
187 <input type=hidden name=login value=$form->{login}>
188 <input type=hidden name=password value=$form->{password}>
191 <input type=submit class=submit name=action value="|
192 . $locale->text('Continue') . qq|">
198 $lxdebug->leave_sub();
202 $lxdebug->enter_sub();
204 CT->search(\%myconfig, \%$form);
207 "$form->{script}?action=list_names&db=$form->{db}&path=$form->{path}&login=$form->{login}&password=$form->{password}&status=$form->{status}";
211 $form->sort_columns(id, name,
212 "$form->{db}number", address,
215 taxnumber, gifi_accno,
217 invnumber, ordnumber,
220 foreach $item (@columns) {
221 if ($form->{"l_$item"} eq "Y") {
222 push @column_index, $item;
224 # add column to href and callback
225 $callback .= "&l_$item=Y";
226 $href .= "&l_$item=Y";
230 ($form->{db} eq "customer")
231 ? $locale->text('Customer Number')
232 : $locale->text('Vendor Number');
234 if ($form->{status} eq 'all') {
235 $option = $locale->text('All');
237 if ($form->{status} eq 'orphaned') {
238 $option .= $locale->text('Orphaned');
241 $callback .= "&name=" . $form->escape($form->{name}, 1);
242 $href .= "&name=" . $form->escape($form->{name});
243 $option .= "\n<br>" . $locale->text('Name') . " : $form->{name}";
245 if ($form->{contact}) {
246 $callback .= "&contact=" . $form->escape($form->{contact}, 1);
247 $href .= "&contact=" . $form->escape($form->{contact});
248 $option .= "\n<br>" . $locale->text('Contact') . " : $form->{contact}";
250 if ($form->{"$form->{db}number"}) {
252 qq|&$form->{db}number=| . $form->escape($form->{"$form->{db}number"}, 1);
254 "&$form->{db}number=" . $form->escape($form->{"$form->{db}number"});
256 "\n<br>" . $locale->text('Number') . qq| : $form->{"$form->{db}number"}|;
258 if ($form->{email}) {
259 $callback .= "&email=" . $form->escape($form->{email}, 1);
260 $href .= "&email=" . $form->escape($form->{email});
261 $option .= "\n<br>" . $locale->text('E-mail') . " : $form->{email}";
264 $form->{callback} = "$callback&sort=$form->{sort}";
265 $callback = $form->escape($form->{callback});
268 qq|<th class=listheading>| . $locale->text('ID') . qq|</th>|;
269 $column_header{"$form->{db}number"} =
270 qq|<th><a class=listheading href=$href&sort=$form->{db}number>$number</a></th>|;
271 $column_header{name} =
272 qq|<th><a class=listheading href=$href&sort=name>|
273 . $locale->text('Name')
275 $column_header{address} =
276 qq|<th><a class=listheading href=$href&sort=address>|
277 . $locale->text('Address')
279 $column_header{contact} =
280 qq|<th><a class=listheading href=$href&sort=contact>|
281 . $locale->text('Contact')
283 $column_header{phone} =
284 qq|<th><a class=listheading href=$href&sort=phone>|
285 . $locale->text('Phone')
287 $column_header{fax} =
288 qq|<th><a class=listheading href=$href&sort=fax>|
289 . $locale->text('Fax')
291 $column_header{email} =
292 qq|<th><a class=listheading href=$href&sort=email>|
293 . $locale->text('E-mail')
296 qq|<th><a class=listheading href=$href&sort=cc>|
297 . $locale->text('Cc')
300 $column_header{taxnumber} =
301 qq|<th><a class=listheading href=$href&sort=taxnumber>|
302 . $locale->text('Tax Number')
304 $column_header{gifi_accno} =
305 qq|<th><a class=listheading href=$href&sort=gifi_accno>|
306 . $locale->text('GIFI')
308 $column_header{sic_code} =
309 qq|<th><a class=listheading href=$href&sort=sic_code>|
310 . $locale->text('SIC')
312 $column_header{business} =
313 qq|<th><a class=listheading href=$href&sort=business>|
314 . $locale->text('Type of Business')
317 $column_header{invnumber} =
318 qq|<th><a class=listheading href=$href&sort=invnumber>|
319 . $locale->text('Invoice')
321 $column_header{ordnumber} =
322 qq|<th><a class=listheading href=$href&sort=ordnumber>|
323 . $locale->text('Order')
325 $column_header{quonumber} =
326 qq|<th><a class=listheading href=$href&sort=quonumber>|
327 . $locale->text('Quotation')
330 $label = ucfirst $form->{db} . "s";
331 $form->{title} = $locale->text($label);
340 <th class=listtop>$form->{title}</th>
349 <tr class=listheading>
352 map { print "$column_header{$_}\n" } @column_index;
358 $ordertype = ($form->{db} eq 'customer') ? 'sales_order' : 'purchase_order';
360 ($form->{db} eq 'customer') ? 'sales_quotation' : 'request_quotation';
362 foreach $ref (@{ $form->{CT} }) {
364 if ($ref->{id} eq $sameid) {
365 map { $column_data{$_} = "<td> </td>" } @column_index;
367 map { $column_data{$_} = "<td>$ref->{$_} </td>" } @column_index;
369 map { $column_data{$_} = "<td>$ref->{$_} </td>" }
370 (invnumber, ordnumber, quonumber);
373 "<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>";
376 $email = $ref->{email};
377 $email =~ s/</\</;
378 $email =~ s/>/\>/;
380 $column_data{email} =
381 qq|<td><a href="mailto:$ref->{email}">$email</a></td>|;
386 if ($ref->{formtype} eq 'invoice') {
387 $column_data{invnumber} =
388 "<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>";
391 if ($ref->{formtype} eq 'order') {
392 $column_data{ordnumber} =
393 "<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>";
396 if ($ref->{formtype} eq 'quotation') {
397 $column_data{quonumber} =
398 "<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>";
407 map { print "$column_data{$_}\n" } @column_index;
413 $sameid = $ref->{id};
422 <td><hr size=3 noshade></td>
427 <form method=post action=$form->{script}>
429 <input name=callback type=hidden value="$form->{callback}">
430 <input name=db type=hidden value=$form->{db}>
432 <input type=hidden name=path value=$form->{path}>
433 <input type=hidden name=login value=$form->{login}>
434 <input type=hidden name=password value=$form->{password}>
436 <input class=submit type=submit name=action value="|
437 . $locale->text('Add') . qq|">|;
439 if ($form->{menubar}) {
440 require "$form->{path}/menu.pl";
451 $lxdebug->leave_sub();
455 $lxdebug->enter_sub();
457 # $locale->text('Edit Customer')
458 # $locale->text('Edit Vendor')
460 CT->get_tuple(\%myconfig, \%$form);
462 # format " into "
463 map { $form->{$_} =~ s/\"/"/g } keys %$form;
465 $form->{title} = "Edit";
468 $form->{discount} *= 100;
473 $lxdebug->leave_sub();
477 $lxdebug->enter_sub();
479 $form->{taxincluded} = ($form->{taxincluded}) ? "checked" : "";
480 $form->{creditlimit} =
481 $form->format_amount(\%myconfig, $form->{creditlimit}, 0);
483 if ($myconfig{role} eq 'admin') {
486 <th align=right nowrap>| . $locale->text('Bcc') . qq|</th>
487 <td><input name=bcc size=35 value="$form->{bcc}"></td>
491 $form->{obsolete} = "checked" if $form->{obsolete};
492 %langs = (de => "deutsch", en => "englisch", fr => "französisch");
493 $lang = qq|<option value=""></option>|;
494 foreach $item (keys %langs) {
495 if ($form->{language} eq $item) {
496 $lang .= qq|<option value="$item" selected>$langs{$item}</option>|;
498 $lang .= qq|<option value="$item">$langs{$item}</option>|;
502 foreach $item (split / /, $form->{taxaccounts}) {
503 if (($form->{tax}{$item}{taxable}) || !($form->{id})) {
505 qq| <input name="tax_$item" value=1 class=checkbox type=checkbox checked> <b>$form->{tax}{$item}{description}</b>|;
508 qq| <input name="tax_$item" value=1 class=checkbox type=checkbox> <b>$form->{tax}{$item}{description}</b>|;
518 <th align=right>| . $locale->text('Taxable') . qq|</th>
523 <td><input name=taxincluded class=checkbox type=checkbox value=1 $form->{taxincluded}></td>
524 <th align=left>| . $locale->text('Tax Included') . qq|</th>
532 $form->{selectbusiness} = qq|<option>\n|;
534 $form->{selectbusiness} .= qq|<option value=$_->{id}>$_->{description}\n|
535 } @{ $form->{all_business} };
536 if ($form->{business_save}) {
537 $form->{selectbusiness} = $form->{business_save};
539 $form->{selectbusiness} =~
540 s/<option value=$form->{business}>/<option value=$form->{business} selected>/;
542 $label = ucfirst $form->{db};
543 $form->{title} = $locale->text("$form->{title} $label");
544 if ($form->{title_save}) {
545 $form->{title} = $form->{title_save};
547 if ($form->{db} eq 'vendor') {
549 <th align=right>| . $locale->text('Kundennummer') . qq|</th>
550 <td><input name=v_customer_id size=10 tabindex=18 maxlength=35 value="$form->{v_customer_id}"></td>
554 if ($form->{db} eq 'customer') {
557 <th align=right>| . $locale->text('KNr. beim Kunden') . qq|</th>
558 <td><input name=c_vendor_id size=10 tabindex=18 maxlength=35 value="$form->{c_vendor_id}"></td>
561 $business_salesman = "";
562 $business = "<th></th><td></td>";
564 $business_salesman = qq|
568 <th align=right>| . $locale->text('Type of Business') . qq|</th>
569 <td><select name=business tabindex=1>$form->{selectbusiness}</select></td>
570 <th align=right>| . $locale->text('Salesman') . qq|</th>
571 <td><input name=salesman tabindex=2 value="$form->{salesman}"></td>
572 <input type=hidden name=salesman_id value="$form->{salesman_id}">
573 <input type=hidden name=oldsalesman value="$form->{oldsalesman}">
578 <th align=right>| . $locale->text('Username') . qq|</th>
579 <td><input name=username maxlength=50 tabindex=22 value="$form->{username}"></td>
580 <th align=right>| . $locale->text('Password') . qq|</th>
581 <td><input name=user_password maxlength=12 tabindex=23 value="$form->{user_password}"></td>|;
584 <th align=right>| . $locale->text('Type of Business') . qq|</th>
585 <td><select name=business tabindex=22>$form->{selectbusiness}</select></td>
589 ## LINET: Create a drop-down box with all prior titles and greetings.
590 CT->query_titles_and_greetings(\%myconfig, \%$form);
592 $select_title = qq| <select name=selected_cp_title><option></option>|;
593 map({ $select_title .= qq|<option>$_</option>|; } @{ $form->{TITLES} });
594 $select_title .= qq|</select>|;
597 qq| <select name=selected_cp_greeting><option></option>|;
598 map({ $select_greeting .= qq|<option>$_</option>|; } @{ $form->{GREETINGS} });
599 $select_greeting .= qq|</select>|;
602 # $locale->text('Customer Number')
603 # $locale->text('Vendor Number')
604 $form->{fokus} = "ct.name";
608 <body onLoad="fokus()">
609 <form method=post name="ct" action=$form->{script}>
613 <th class=listtop>$form->{title}</th>
618 <tr class=listheading>
619 <th class=listheading colspan=2 width=50%>|
620 . $locale->text('Billing Address')
622 <th class=listheading width=50%>|
623 . $locale->text('Shipping Address')
629 <th align=right nowrap>| . $locale->text($label . ' Number') . qq|</th>
630 <td><input name="$form->{db}number" size=35 maxlength=35 value="$form->{"$form->{db}number"}"></td>
633 <th align=right nowrap>| . $locale->text('Company Name') . qq|</th>
634 <td><input name=name size=35 maxlength=35 tabindex=1 value="$form->{name}"></td>
635 <td><input name=shiptoname size=35 maxlength=75 value="$form->{shiptoname}"></td>
638 <th align=right nowrap>| . $locale->text('Abteilung') . qq|</th>
639 <td><input name=department_1 size=16 maxlength=75 tabindex=2 value="$form->{department_1}">
640 <input name=department_2 size=16 maxlength=75 tabindex=3 value="$form->{department_2}"></td>
641 <td><input name=shiptodepartment_1 size=16 maxlength=75 value="$form->{shiptodepartment_1}">
642 <input name=shiptodepartment_2 size=16 maxlength=75 value="$form->{shiptodepartment_2}"></td>
645 <th align=right nowrap>| . $locale->text('Street') . qq|</th>
646 <td><input name=street size=35 tabindex=4 maxlength=75 value="$form->{street}"></td>
647 <td><input name=shiptostreet size=35 maxlength=35 value="$form->{shiptostreet}"></td>
650 <th align=right nowrap>|
651 . $locale->text('Zipcode') . "/"
652 . $locale->text('City')
654 <td><input name=zipcode size=5 tabindex=5 maxlength=10 value="$form->{zipcode}">
655 <input name=city size=30 tabindex=6 maxlength=75 value="$form->{city}"></td>
656 <td><input name=shiptozipcode size=5 maxlength=10 value="$form->{shiptozipcode}">
657 <input name=shiptocity size=30 maxlength=75 value="$form->{shiptocity}"></td>
660 <th align=right nowrap>| . $locale->text('Country') . qq|</th>
661 <td><input name=country size=35 tabindex=7 maxlength=75 value="$form->{country}"></td>
662 <td><input name=shiptocountry size=35 maxlength=35 value="$form->{shiptocountry}"></td>
665 <th align=right nowrap>| . $locale->text('Contact') . qq|</th>
666 <td><input name=contact size=28 tabindex=8 maxlength=75 value="$form->{contact}"></td>
667 <td><input name=shiptocontact size=30 maxlength=75 value="$form->{shiptocontact}"></td>
670 <th align=right nowrap>| . $locale->text('Phone') . qq|</th>
671 <td><input name=phone size=30 tabindex=9 maxlength=30 value="$form->{phone}"></td>
672 <td><input name=shiptophone size=30 maxlength=30 value="$form->{shiptophone}"></td>
675 <th align=right nowrap>| . $locale->text('Fax') . qq|</th>
676 <td><input name=fax size=30 tabindex=10 maxlength=30 value="$form->{fax}"></td>
677 <td><input name=shiptofax size=30 maxlength=30 value="$form->{shiptofax}"></td>
680 <th align=right nowrap>| . $locale->text('E-mail') . qq|</th>
681 <td><input name=email tabindex=11 size=45 value="$form->{email}"></td>
682 <td><input name=shiptoemail size=45 value="$form->{shiptoemail}"></td>
685 <th align=right nowrap>| . $locale->text('Homepage') . qq|</th>
686 <td><input name=homepage tabindex=12 size=45 value="$form->{homepage}"></td>
690 ##LINET - added fields for contact person
693 <input type=hidden name=cp_id value=$form->{cp_id}>
696 <th align=right nowrap>|
697 . $locale->text('Contact Person')
702 <th align=left nowrap>| . $locale->text('Greeting') . qq|</th>
703 <td><input name=cp_greeting size=30 maxlength=30 value="$form->{cp_greeting}">
704 $select_greeting</td>
705 <th align=left nowrap>| . $locale->text('Title') . qq|</th>
706 <td><input name=cp_title size=30 maxlength=30 value="$form->{cp_title}">
711 <th align=left nowrap>|
712 . $locale->text('Given Name')
714 <td><input name=cp_givenname size=30 maxlength=40 value="$form->{cp_givenname}"></td>
715 <th align=left nowrap>| . $locale->text('Name') . qq|</th>
716 <td><input name=cp_name size=30 maxlength=40 value="$form->{cp_name}"></td>
720 <th align=left nowrap>| . $locale->text('Phone1') . qq|</th>
721 <td><input name=cp_phone1 size=30 maxlength=30 value="$form->{cp_phone1}"></td>
722 <th align=left nowrap>| . $locale->text('Phone2') . qq|</th>
723 <td><input name=cp_phone2 size=30 maxlength=30 value="$form->{cp_phone2}"></td>
727 <th align=left nowrap>| . $locale->text('E-mail') . qq|</th>
728 <td><input name=cp_email size=30 maxlength=40 value="$form->{cp_email}"></td>
734 <tr height="5"></tr>|;
745 <th align=right>| . $locale->text('Credit Limit') . qq|</th>
746 <td><input name=creditlimit tabindex=13 size=9 value="$form->{creditlimit}"></td>
747 <th align=right>| . $locale->text('Terms: Net') . qq|</th>
748 <td><input name=terms tabindex=14 size=2 value="$form->{terms}">|
749 . $locale->text('days')
751 <th align=right>| . $locale->text('Discount') . qq|</th>
752 <td><input name=discount tabindex=15 size=4 value="$form->{discount}">
756 <th align=right>| . $locale->text('Tax Number / SSN') . qq|</th>
757 <td><input name=taxnumber tabindex=16 size=20 value="$form->{taxnumber}"></td>
758 <th align=right>| . $locale->text('USt-IdNr.') . qq|</th>
759 <td><input name=ustid tabindex=17 size=20 value="$form->{ustid}"></td>
763 <th align=right>| . $locale->text('Account Number') . qq|</th>
764 <td><input name=account_number size=10 tabindex=19 value="$form->{account_number}"></td>
765 <th align=right>| . $locale->text('Bank Code Number') . qq|</th>
766 <td><input name=bank_code size=10 tabindex=20 value="$form->{bank_code}"></td>
767 <th align=right>| . $locale->text('Bank') . qq|</th>
768 <td><input name=bank size=30 tabindex=21 value="$form->{bank}"></td>
772 <th align=right>| . $locale->text('Language') . qq|</th>
773 <td><select name=language tabindex=23>$lang
778 <td align=right>| . $locale->text('Obsolete') . qq|</td>
779 <td><input name=obsolete class=checkbox type=checkbox value=1 $form->{obsolete}></td>
785 <th align=left nowrap>| . $locale->text('Notes') . qq|</th>
788 <td><textarea name=notes rows=3 cols=60 wrap=soft>$form->{notes}</textarea></td>
791 <td><hr size=3 noshade></td>
796 $lxdebug->leave_sub();
800 $lxdebug->enter_sub();
802 $label = ucfirst $form->{db};
804 ($form->{db} eq 'customer')
805 ? $locale->text('Save and Quotation')
806 : $locale->text('Save and RFQ');
808 ($form->{db} eq 'customer')
809 ? $locale->text('Save and AR Transaction')
810 : $locale->text('Save and AP Transaction');
813 qq|<input class=submit type=submit name=action accesskey="u" value="|
814 . $locale->text("Update") . qq|">|;
819 ##<input class=submit type=submit name=action value="|.$locale->text("Save and Quotation").qq|">
820 ##<input class=submit type=submit name=action value="|.$locale->text("Save and RFQ").qq|">
821 ##<input class=submit type=submit name=action value="|.$locale->text("Save and AR Transaction").qq|">
822 ##<input class=submit type=submit name=action value="|.$locale->text("Save and AP Transaction").qq|">
825 <input name=id type=hidden value=$form->{id}>
826 <input name=taxaccounts type=hidden value="$form->{taxaccounts}">
827 <input name=business_save type=hidden value="$form->{selectbusiness}">
828 <input name=title_save type=hidden value="$form->{title}">
830 <input type=hidden name=path value=$form->{path}>
831 <input type=hidden name=login value=$form->{login}>
832 <input type=hidden name=password value=$form->{password}>
834 <input type=hidden name=callback value="$form->{callback}">
835 <input type=hidden name=db value=$form->{db}>
839 <input class=submit type=submit name=action accesskey="s" value="|
840 . $locale->text("Save") . qq|">
841 <input class=submit type=submit name=action value="$arap">
842 <input class=submit type=submit name=action value="|
843 . $locale->text("Save and Invoice") . qq|">
844 <input class=submit type=submit name=action value="|
845 . $locale->text("Save and Order") . qq|">
846 <input class=submit type=submit name=action value="$quotation">
849 if ($form->{id} && $form->{status} eq 'orphaned') {
850 print qq|<input class=submit type=submit name=action value="|
851 . $locale->text('Delete')
855 if ($form->{menubar}) {
856 require "$form->{path}/menu.pl";
868 $lxdebug->leave_sub();
871 sub add_transaction {
872 $lxdebug->enter_sub();
874 $form->isblank("name", $locale->text("Name missing!"));
875 &{"CT::save_$form->{db}"}("", \%myconfig, \%$form);
877 $form->{callback} = $form->escape($form->{callback}, 1);
878 $name = $form->escape("$form->{name}", 1);
881 "$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}";
885 $lxdebug->leave_sub();
888 sub save_and_ap_transaction {
889 $lxdebug->enter_sub();
891 $form->{script} = "ap.pl";
894 $lxdebug->leave_sub();
897 sub save_and_ar_transaction {
898 $lxdebug->enter_sub();
900 $form->{script} = "ar.pl";
903 $lxdebug->leave_sub();
906 sub save_and_invoice {
907 $lxdebug->enter_sub();
909 $form->{script} = ($form->{db} eq 'customer') ? "is.pl" : "ir.pl";
910 $form->{type} = "invoice";
913 $lxdebug->leave_sub();
917 $lxdebug->enter_sub();
919 $form->{script} = "oe.pl";
920 $form->{type} = "request_quotation";
923 $lxdebug->leave_sub();
926 sub save_and_quotation {
927 $lxdebug->enter_sub();
929 $form->{script} = "oe.pl";
930 $form->{type} = "sales_quotation";
933 $lxdebug->leave_sub();
937 $lxdebug->enter_sub();
939 $form->{script} = "oe.pl";
941 ($form->{db} eq 'customer') ? "sales_order" : "purchase_order";
944 $lxdebug->leave_sub();
948 $lxdebug->enter_sub();
950 # $locale->text('Customer saved!')
951 # $locale->text('Vendor saved!')
953 $msg = ucfirst $form->{db};
956 $form->isblank("name", $locale->text("Name missing!"));
957 if ($vertreter && $form->{db} eq "customer") {
958 $form->isblank("salesman_id", $locale->text("Salesman missing!"));
960 &{"CT::save_$form->{db}"}("", \%myconfig, \%$form);
962 $form->redirect($locale->text($msg));
964 $lxdebug->leave_sub();
968 $lxdebug->enter_sub();
970 # $locale->text('Customer deleted!')
971 # $locale->text('Cannot delete customer!')
972 # $locale->text('Vendor deleted!')
973 # $locale->text('Cannot delete vendor!')
975 CT->delete(\%myconfig, \%$form);
977 $msg = ucfirst $form->{db};
979 $form->redirect($locale->text($msg));
981 $msg = "Cannot delete $form->{db}";
982 $form->error($locale->text($msg));
984 $lxdebug->leave_sub();
988 $lxdebug->enter_sub();
993 $lxdebug->leave_sub();
997 $lxdebug->enter_sub();
999 &check_salesman($form->{salesman});
1001 # $form->get_salesman(\%myconfig, $form->{salesman});
1003 $lxdebug->leave_sub();
1006 sub check_salesman {
1007 $lxdebug->enter_sub();
1011 my ($new_name, $new_id) = split /--/, $form->{$name};
1014 # check name, combine name and id
1015 if ($form->{"oldsalesman"} ne $form->{"salesman"}) {
1017 # return one name or a list of names in $form->{name_list}
1018 if (($i = $form->get_salesman(\%myconfig, $name)) > 1) {
1019 &select_salesman($name);
1026 $form->{"salesman_id"} = $form->{salesman_list}[0]->{id};
1027 $form->{salesman} = $form->{salesman_list}[0]->{name};
1028 $form->{"oldsalesman"} = $form->{salesman};
1032 # name is not on file
1033 # $locale->text('Customer not on file!')
1034 # $locale->text('Vendor not on file!')
1035 $msg = ucfirst $name . " not on file or locked!";
1036 $form->error($locale->text($msg));
1040 $lxdebug->leave_sub();
1045 sub select_salesman {
1046 $lxdebug->enter_sub();
1050 @column_index = qw(ndx name);
1052 $label = ucfirst $table;
1053 $column_data{ndx} = qq|<th> </th>|;
1054 $column_data{name} =
1055 qq|<th class=listheading>| . $locale->text($label) . qq|</th>|;
1057 # list items with radio button on a form
1060 $title = $locale->text('Select from one of the names below');
1065 <form method=post action=$form->{script}>
1069 <th class=listtop>$title</th>
1075 <tr class=listheading>|;
1077 map { print "\n$column_data{$_}" } @column_index;
1084 foreach $ref (@{ $form->{salesman_list} }) {
1085 $checked = ($i++) ? "" : "checked";
1087 $ref->{name} =~ s/\"/"/g;
1090 qq|<td><input name=ndx class=radio type=radio value=$i $checked></td>|;
1091 $column_data{name} =
1092 qq|<td><input name="new_name_$i" type=hidden value="$ref->{name}">$ref->{name}</td>|;
1097 <tr class=listrow$j>|;
1099 map { print "\n$column_data{$_}" } @column_index;
1104 <input name="new_id_$i" type=hidden value=$ref->{id}>
1115 <td><hr size=3 noshade></td>
1119 <input name=lastndx type=hidden value=$i>
1124 map { delete $form->{$_} } qw(action name_list header);
1126 # save all other form variables
1127 foreach $key (keys %${form}) {
1128 $form->{$key} =~ s/\"/"/g;
1129 print qq|<input name=$key type=hidden value="$form->{$key}">\n|;
1133 <input type=hidden name=nextsub value=salesman_selected>
1135 <input type=hidden name=vc value=$table>
1137 <input class=submit type=submit name=action value="|
1138 . $locale->text('Continue') . qq|">
1145 $lxdebug->leave_sub();
1148 sub salesman_selected {
1149 $lxdebug->enter_sub();
1151 # replace the variable with the one checked
1153 # index for new item
1156 $form->{salesman} = $form->{"new_name_$i"};
1157 $form->{"salesman_id"} = $form->{"new_id_$i"};
1158 $form->{"oldsalesman"} = $form->{salesman};
1160 # delete all the new_ variables
1161 for $i (1 .. $form->{lastndx}) {
1162 map { delete $form->{"new_${_}_$i"} } (id, name);
1165 map { delete $form->{$_} } qw(ndx lastndx nextsub);
1169 $lxdebug->leave_sub();
1172 sub continue { &{ $form->{nextsub} } }