use strict;
-sub get_vc {
- $main::lxdebug->enter_sub();
-
- my ($self, $myconfig, $form) = @_;
-
- # connect to database
- my $dbh = $form->dbconnect($myconfig);
-
- my %arap = (invoice => 'ar',
- sales_order => 'oe',
- purchase_order => 'oe',
- sales_quotation => 'oe',
- request_quotation => 'oe',
- check => 'ap',
- receipt => 'ar');
-
- my $vc = $form->{vc} eq "customer" ? "customer" : "vendor";
- my $arap_type = defined($arap{$form->{type}}) ? $arap{$form->{type}} : 'ar';
-
- my $query =
- qq|SELECT count(*) | .
- qq|FROM (SELECT DISTINCT ON (vc.id) vc.id FROM $vc vc, $arap_type a, status s | .
- qq| WHERE a.${vc}_id = vc.id AND s.trans_id = a.id AND s.formname = ? | .
- qq| AND s.spoolfile IS NOT NULL) AS total|;
-
- my ($count) = selectrow_query($form, $dbh, $query, $form->{type});
-
- # build selection list
- if ($count < $myconfig->{vclimit}) {
- $query =
- qq|SELECT DISTINCT ON (vc.id) vc.id, vc.name | .
- qq|FROM $vc vc, $arap_type a, status s | .
- qq|WHERE a.${vc}_id = vc.id AND s.trans_id = a.id AND s.formname = ? | .
- qq| AND s.spoolfile IS NOT NULL|;
-
- my $sth = $dbh->prepare($query);
- $sth->execute($form->{type}) || $form->dberror($query . " ($form->{type})");
-
- $form->{"all_${vc}"} = [];
- while (my $ref = $sth->fetchrow_hashref("NAME_lc")) {
- push @{ $form->{"all_${vc}"} }, $ref;
- }
- $sth->finish;
- }
-
- $main::lxdebug->leave_sub();
-}
-
sub payment_accounts {
$main::lxdebug->enter_sub();
}
1;
-
assert_bp_access();
- # setup customer/vendor selection
- BP->get_vc(\%::myconfig, $::form);
-
my %label = (
invoice => { title => $::locale->text('Sales Invoices'), invnumber => 1, ordnumber => 1 },
sales_order => { title => $::locale->text('Sales Orders'), ordnumber => 1, },
<table>
<tr>
<th align=right>[% 'Customer' | $T8 %]</th>
- <td colspan=3>
- [%- IF vc == 'customer' ? all_customer.size : all_vendor.size %]
- [%- INCLUDE 'generic/multibox.html'
- name = vc,
- DATA = vc == 'customer' ? all_customer : all_vendor,
- id_sub = 'vc_keys',
- label_sub = 'vc_keys',
- select = vc_select,
- limit = vclimit,
- show_empty = 1,
- allow_textbox = 1,
- -%]
- [%- ELSE %]
- [% L.input_tag(vc, '', size=35) %]
- [%- END %]
-</td>
+ <td colspan=3>[% L.input_tag(vc, '', size=35) %]</td>
</tr>
[% IF show_accounts %]
<tr>
[% L.submit_tag('action', LxERP.t8('Continue')) %]
</form>
-
-