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>|;
599 { $select_greeting .= qq|<option>$_</option>|; } @{ $form->{GREETINGS} });
600 $select_greeting .= qq|</select>|;
603 # $locale->text('Customer Number')
604 # $locale->text('Vendor Number')
605 $form->{fokus} = "ct.name";
609 <body onLoad="fokus()">
610 <form method=post name="ct" action=$form->{script}>
614 <th class=listtop>$form->{title}</th>
619 <tr class=listheading>
620 <th class=listheading colspan=2 width=50%>|
621 . $locale->text('Billing Address')
623 <th class=listheading width=50%>|
624 . $locale->text('Shipping Address')
630 <th align=right nowrap>| . $locale->text($label . ' Number') . qq|</th>
631 <td><input name="$form->{db}number" size=35 maxlength=35 value="$form->{"$form->{db}number"}"></td>
634 <th align=right nowrap>| . $locale->text('Company Name') . qq|</th>
635 <td><input name=name size=35 maxlength=35 tabindex=1 value="$form->{name}"></td>
636 <td><input name=shiptoname size=35 maxlength=75 value="$form->{shiptoname}"></td>
639 <th align=right nowrap>| . $locale->text('Abteilung') . qq|</th>
640 <td><input name=department_1 size=16 maxlength=75 tabindex=2 value="$form->{department_1}">
641 <input name=department_2 size=16 maxlength=75 tabindex=3 value="$form->{department_2}"></td>
642 <td><input name=shiptodepartment_1 size=16 maxlength=75 value="$form->{shiptodepartment_1}">
643 <input name=shiptodepartment_2 size=16 maxlength=75 value="$form->{shiptodepartment_2}"></td>
646 <th align=right nowrap>| . $locale->text('Street') . qq|</th>
647 <td><input name=street size=35 tabindex=4 maxlength=75 value="$form->{street}"></td>
648 <td><input name=shiptostreet size=35 maxlength=35 value="$form->{shiptostreet}"></td>
651 <th align=right nowrap>|
652 . $locale->text('Zipcode') . "/"
653 . $locale->text('City')
655 <td><input name=zipcode size=5 tabindex=5 maxlength=10 value="$form->{zipcode}">
656 <input name=city size=30 tabindex=6 maxlength=75 value="$form->{city}"></td>
657 <td><input name=shiptozipcode size=5 maxlength=10 value="$form->{shiptozipcode}">
658 <input name=shiptocity size=30 maxlength=75 value="$form->{shiptocity}"></td>
661 <th align=right nowrap>| . $locale->text('Country') . qq|</th>
662 <td><input name=country size=35 tabindex=7 maxlength=75 value="$form->{country}"></td>
663 <td><input name=shiptocountry size=35 maxlength=35 value="$form->{shiptocountry}"></td>
666 <th align=right nowrap>| . $locale->text('Contact') . qq|</th>
667 <td><input name=contact size=28 tabindex=8 maxlength=75 value="$form->{contact}"></td>
668 <td><input name=shiptocontact size=30 maxlength=75 value="$form->{shiptocontact}"></td>
671 <th align=right nowrap>| . $locale->text('Phone') . qq|</th>
672 <td><input name=phone size=30 tabindex=9 maxlength=30 value="$form->{phone}"></td>
673 <td><input name=shiptophone size=30 maxlength=30 value="$form->{shiptophone}"></td>
676 <th align=right nowrap>| . $locale->text('Fax') . qq|</th>
677 <td><input name=fax size=30 tabindex=10 maxlength=30 value="$form->{fax}"></td>
678 <td><input name=shiptofax size=30 maxlength=30 value="$form->{shiptofax}"></td>
681 <th align=right nowrap>| . $locale->text('E-mail') . qq|</th>
682 <td><input name=email tabindex=11 size=45 value="$form->{email}"></td>
683 <td><input name=shiptoemail size=45 value="$form->{shiptoemail}"></td>
686 <th align=right nowrap>| . $locale->text('Homepage') . qq|</th>
687 <td><input name=homepage tabindex=12 size=45 value="$form->{homepage}"></td>
691 ##LINET - added fields for contact person
694 <input type=hidden name=cp_id value=$form->{cp_id}>
697 <th align=right nowrap>|
698 . $locale->text('Contact Person')
703 <th align=left nowrap>| . $locale->text('Greeting') . qq|</th>
704 <td><input name=cp_greeting size=30 maxlength=30 value="$form->{cp_greeting}">
705 $select_greeting</td>
706 <th align=left nowrap>| . $locale->text('Title') . qq|</th>
707 <td><input name=cp_title size=30 maxlength=30 value="$form->{cp_title}">
712 <th align=left nowrap>|
713 . $locale->text('Given Name')
715 <td><input name=cp_givenname size=30 maxlength=40 value="$form->{cp_givenname}"></td>
716 <th align=left nowrap>| . $locale->text('Name') . qq|</th>
717 <td><input name=cp_name size=30 maxlength=40 value="$form->{cp_name}"></td>
721 <th align=left nowrap>| . $locale->text('Phone1') . qq|</th>
722 <td><input name=cp_phone1 size=30 maxlength=30 value="$form->{cp_phone1}"></td>
723 <th align=left nowrap>| . $locale->text('Phone2') . qq|</th>
724 <td><input name=cp_phone2 size=30 maxlength=30 value="$form->{cp_phone2}"></td>
728 <th align=left nowrap>| . $locale->text('E-mail') . qq|</th>
729 <td><input name=cp_email size=30 maxlength=40 value="$form->{cp_email}"></td>
735 <tr height="5"></tr>|;
746 <th align=right>| . $locale->text('Credit Limit') . qq|</th>
747 <td><input name=creditlimit tabindex=13 size=9 value="$form->{creditlimit}"></td>
748 <th align=right>| . $locale->text('Terms: Net') . qq|</th>
749 <td><input name=terms tabindex=14 size=2 value="$form->{terms}">|
750 . $locale->text('days')
752 <th align=right>| . $locale->text('Discount') . qq|</th>
753 <td><input name=discount tabindex=15 size=4 value="$form->{discount}">
757 <th align=right>| . $locale->text('Tax Number / SSN') . qq|</th>
758 <td><input name=taxnumber tabindex=16 size=20 value="$form->{taxnumber}"></td>
759 <th align=right>| . $locale->text('USt-IdNr.') . qq|</th>
760 <td><input name=ustid tabindex=17 size=20 value="$form->{ustid}"></td>
764 <th align=right>| . $locale->text('Account Number') . qq|</th>
765 <td><input name=account_number size=10 tabindex=19 value="$form->{account_number}"></td>
766 <th align=right>| . $locale->text('Bank Code Number') . qq|</th>
767 <td><input name=bank_code size=10 tabindex=20 value="$form->{bank_code}"></td>
768 <th align=right>| . $locale->text('Bank') . qq|</th>
769 <td><input name=bank size=30 tabindex=21 value="$form->{bank}"></td>
773 <th align=right>| . $locale->text('Language') . qq|</th>
774 <td><select name=language tabindex=23>$lang
779 <td align=right>| . $locale->text('Obsolete') . qq|</td>
780 <td><input name=obsolete class=checkbox type=checkbox value=1 $form->{obsolete}></td>
786 <th align=left nowrap>| . $locale->text('Notes') . qq|</th>
789 <td><textarea name=notes rows=3 cols=60 wrap=soft>$form->{notes}</textarea></td>
792 <td><hr size=3 noshade></td>
797 $lxdebug->leave_sub();
801 $lxdebug->enter_sub();
803 $label = ucfirst $form->{db};
805 ($form->{db} eq 'customer')
806 ? $locale->text('Save and Quotation')
807 : $locale->text('Save and RFQ');
809 ($form->{db} eq 'customer')
810 ? $locale->text('Save and AR Transaction')
811 : $locale->text('Save and AP Transaction');
814 qq|<input class=submit type=submit name=action accesskey="u" value="|
815 . $locale->text("Update") . qq|">|;
820 ##<input class=submit type=submit name=action value="|.$locale->text("Save and Quotation").qq|">
821 ##<input class=submit type=submit name=action value="|.$locale->text("Save and RFQ").qq|">
822 ##<input class=submit type=submit name=action value="|.$locale->text("Save and AR Transaction").qq|">
823 ##<input class=submit type=submit name=action value="|.$locale->text("Save and AP Transaction").qq|">
826 <input name=id type=hidden value=$form->{id}>
827 <input name=taxaccounts type=hidden value="$form->{taxaccounts}">
828 <input name=business_save type=hidden value="$form->{selectbusiness}">
829 <input name=title_save type=hidden value="$form->{title}">
831 <input type=hidden name=path value=$form->{path}>
832 <input type=hidden name=login value=$form->{login}>
833 <input type=hidden name=password value=$form->{password}>
835 <input type=hidden name=callback value="$form->{callback}">
836 <input type=hidden name=db value=$form->{db}>
840 <input class=submit type=submit name=action accesskey="s" value="|
841 . $locale->text("Save") . qq|">
842 <input class=submit type=submit name=action value="$arap">
843 <input class=submit type=submit name=action value="|
844 . $locale->text("Save and Invoice") . qq|">
845 <input class=submit type=submit name=action value="|
846 . $locale->text("Save and Order") . qq|">
847 <input class=submit type=submit name=action value="$quotation">
850 if ($form->{id} && $form->{status} eq 'orphaned') {
851 print qq|<input class=submit type=submit name=action value="|
852 . $locale->text('Delete')
856 if ($form->{menubar}) {
857 require "$form->{path}/menu.pl";
869 $lxdebug->leave_sub();
872 sub add_transaction {
873 $lxdebug->enter_sub();
875 $form->isblank("name", $locale->text("Name missing!"));
876 &{"CT::save_$form->{db}"}("", \%myconfig, \%$form);
878 $form->{callback} = $form->escape($form->{callback}, 1);
879 $name = $form->escape("$form->{name}", 1);
882 "$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}";
886 $lxdebug->leave_sub();
889 sub save_and_ap_transaction {
890 $lxdebug->enter_sub();
892 $form->{script} = "ap.pl";
895 $lxdebug->leave_sub();
898 sub save_and_ar_transaction {
899 $lxdebug->enter_sub();
901 $form->{script} = "ar.pl";
904 $lxdebug->leave_sub();
907 sub save_and_invoice {
908 $lxdebug->enter_sub();
910 $form->{script} = ($form->{db} eq 'customer') ? "is.pl" : "ir.pl";
911 $form->{type} = "invoice";
914 $lxdebug->leave_sub();
918 $lxdebug->enter_sub();
920 $form->{script} = "oe.pl";
921 $form->{type} = "request_quotation";
924 $lxdebug->leave_sub();
927 sub save_and_quotation {
928 $lxdebug->enter_sub();
930 $form->{script} = "oe.pl";
931 $form->{type} = "sales_quotation";
934 $lxdebug->leave_sub();
938 $lxdebug->enter_sub();
940 $form->{script} = "oe.pl";
942 ($form->{db} eq 'customer') ? "sales_order" : "purchase_order";
945 $lxdebug->leave_sub();
949 $lxdebug->enter_sub();
951 # $locale->text('Customer saved!')
952 # $locale->text('Vendor saved!')
954 $msg = ucfirst $form->{db};
957 $form->isblank("name", $locale->text("Name missing!"));
958 if ($vertreter && $form->{db} eq "customer") {
959 $form->isblank("salesman_id", $locale->text("Salesman missing!"));
961 &{"CT::save_$form->{db}"}("", \%myconfig, \%$form);
963 $form->redirect($locale->text($msg));
965 $lxdebug->leave_sub();
969 $lxdebug->enter_sub();
971 # $locale->text('Customer deleted!')
972 # $locale->text('Cannot delete customer!')
973 # $locale->text('Vendor deleted!')
974 # $locale->text('Cannot delete vendor!')
976 CT->delete(\%myconfig, \%$form);
978 $msg = ucfirst $form->{db};
980 $form->redirect($locale->text($msg));
982 $msg = "Cannot delete $form->{db}";
983 $form->error($locale->text($msg));
985 $lxdebug->leave_sub();
989 $lxdebug->enter_sub();
994 $lxdebug->leave_sub();
998 $lxdebug->enter_sub();
1000 &check_salesman($form->{salesman});
1002 # $form->get_salesman(\%myconfig, $form->{salesman});
1004 $lxdebug->leave_sub();
1007 sub check_salesman {
1008 $lxdebug->enter_sub();
1012 my ($new_name, $new_id) = split /--/, $form->{$name};
1015 # check name, combine name and id
1016 if ($form->{"oldsalesman"} ne $form->{"salesman"}) {
1018 # return one name or a list of names in $form->{name_list}
1019 if (($i = $form->get_salesman(\%myconfig, $name)) > 1) {
1020 &select_salesman($name);
1027 $form->{"salesman_id"} = $form->{salesman_list}[0]->{id};
1028 $form->{salesman} = $form->{salesman_list}[0]->{name};
1029 $form->{"oldsalesman"} = $form->{salesman};
1033 # name is not on file
1034 # $locale->text('Customer not on file!')
1035 # $locale->text('Vendor not on file!')
1036 $msg = ucfirst $name . " not on file or locked!";
1037 $form->error($locale->text($msg));
1041 $lxdebug->leave_sub();
1046 sub select_salesman {
1047 $lxdebug->enter_sub();
1051 @column_index = qw(ndx name);
1053 $label = ucfirst $table;
1054 $column_data{ndx} = qq|<th> </th>|;
1055 $column_data{name} =
1056 qq|<th class=listheading>| . $locale->text($label) . qq|</th>|;
1058 # list items with radio button on a form
1061 $title = $locale->text('Select from one of the names below');
1066 <form method=post action=$form->{script}>
1070 <th class=listtop>$title</th>
1076 <tr class=listheading>|;
1078 map { print "\n$column_data{$_}" } @column_index;
1085 foreach $ref (@{ $form->{salesman_list} }) {
1086 $checked = ($i++) ? "" : "checked";
1088 $ref->{name} =~ s/\"/"/g;
1091 qq|<td><input name=ndx class=radio type=radio value=$i $checked></td>|;
1092 $column_data{name} =
1093 qq|<td><input name="new_name_$i" type=hidden value="$ref->{name}">$ref->{name}</td>|;
1098 <tr class=listrow$j>|;
1100 map { print "\n$column_data{$_}" } @column_index;
1105 <input name="new_id_$i" type=hidden value=$ref->{id}>
1116 <td><hr size=3 noshade></td>
1120 <input name=lastndx type=hidden value=$i>
1125 map { delete $form->{$_} } qw(action name_list header);
1127 # save all other form variables
1128 foreach $key (keys %${form}) {
1129 $form->{$key} =~ s/\"/"/g;
1130 print qq|<input name=$key type=hidden value="$form->{$key}">\n|;
1134 <input type=hidden name=nextsub value=salesman_selected>
1136 <input type=hidden name=vc value=$table>
1138 <input class=submit type=submit name=action value="|
1139 . $locale->text('Continue') . qq|">
1146 $lxdebug->leave_sub();
1149 sub salesman_selected {
1150 $lxdebug->enter_sub();
1152 # replace the variable with the one checked
1154 # index for new item
1157 $form->{salesman} = $form->{"new_name_$i"};
1158 $form->{"salesman_id"} = $form->{"new_id_$i"};
1159 $form->{"oldsalesman"} = $form->{salesman};
1161 # delete all the new_ variables
1162 for $i (1 .. $form->{lastndx}) {
1163 map { delete $form->{"new_${_}_$i"} } (id, name);
1166 map { delete $form->{$_} } qw(ndx lastndx nextsub);
1170 $lxdebug->leave_sub();
1173 sub continue { &{ $form->{nextsub} } }