package AP;
use SL::DBUtils;
+use SL::IO;
use SL::MoreCommon;
+use Data::Dumper;
+
use strict;
sub post_transaction {
(split(/--/, $form->{"AP_amount_$i"}))[0];
}
($form->{AP_amounts}{payables}) = split(/--/, $form->{APselected});
- ($form->{AP}{payables}) = split(/--/, $form->{APselected});
+ ($form->{AP_payables}) = split(/--/, $form->{APselected});
# reverse and parse amounts
for my $i (1 .. $form->{rowcount}) {
# amount for total AP
$form->{payables} = $form->{invtotal};
- $form->{datepaid} = $form->{transdate} unless ($form->{datepaid});
- my $datepaid = ($form->{invpaid} != 0) ? $form->{datepaid} : undef;
-
# update exchangerate
if (($form->{currency} ne $form->{defaultcurrency}) && !$exchangerate) {
$form->update_exchangerate($dbh, $form->{currency}, $form->{transdate}, 0,
$query = qq|UPDATE ap SET
invnumber = ?, transdate = ?, ordnumber = ?, vendor_id = ?, taxincluded = ?,
- amount = ?, duedate = ?, paid = ?, datepaid = ?, netamount = ?,
+ amount = ?, duedate = ?, paid = ?, netamount = ?,
curr = ?, notes = ?, department_id = ?, storno = ?, storno_id = ?
WHERE id = ?|;
@values = ($form->{invnumber}, conv_date($form->{transdate}),
$form->{ordnumber}, conv_i($form->{vendor_id}),
$form->{taxincluded} ? 't' : 'f', $form->{invtotal},
conv_date($form->{duedate}), $form->{invpaid},
- conv_date($datepaid), $form->{netamount},
+ $form->{netamount},
$form->{currency}, $form->{notes},
conv_i($form->{department_id}), $form->{storno},
$form->{storno_id}, $form->{id});
# get paid account
- ($form->{AP}{"paid_$i"}) = split(/--/, $form->{"AP_paid_$i"});
+ ($form->{"AP_paid_account_$i"}) = split(/--/, $form->{"AP_paid_$i"});
$form->{"datepaid_$i"} = $form->{transdate}
unless ($form->{"datepaid_$i"});
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, project_id, taxkey) | .
qq|VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, ?, | .
qq| (SELECT taxkey_id FROM chart WHERE accno = ?))|;
- @values = ($form->{id}, $form->{AP}{payables}, $amount,
+ @values = ($form->{id}, $form->{AP_payables}, $amount,
conv_date($form->{"datepaid_$i"}), $project_id,
- $form->{AP}{payables});
+ $form->{AP_payables});
do_query($form, $dbh, $query, @values);
}
$form->{payables} = $amount;
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, source, memo, project_id, taxkey) | .
qq|VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, ?, ?, ?, | .
qq| (SELECT taxkey_id FROM chart WHERE accno = ?))|;
- @values = ($form->{id}, $form->{AP}{"paid_$i"}, $form->{"paid_$i"},
+ @values = ($form->{id}, $form->{"AP_paid_account_$i"}, $form->{"paid_$i"},
conv_date($form->{"datepaid_$i"}), $form->{"source_$i"},
- $form->{"memo_$i"}, $project_id, $form->{AP}{"paid_$i"});
+ $form->{"memo_$i"}, $project_id, $form->{"AP_paid_account_$i"});
do_query($form, $dbh, $query, @values);
# add exchange rate difference
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, fx_transaction, cleared, project_id, taxkey) | .
qq|VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, 't', 'f', ?, | .
qq| (SELECT taxkey_id FROM chart WHERE accno = ?))|;
- @values = ($form->{id}, $form->{AP}{"paid_$i"}, $amount,
+ @values = ($form->{id}, $form->{"AP_paid_account_$i"}, $amount,
conv_date($form->{"datepaid_$i"}), $project_id,
- $form->{AP}{"paid_$i"});
+ $form->{"AP_paid_account_$i"});
do_query($form, $dbh, $query, @values);
}
do_query($form, $dbh, $query, $form->{invpaid}, $form->{invpaid} ? conv_date($form->{datepaid}) : undef, conv_i($form->{id}));
}
+ IO->set_datepaid(table => 'ap', id => $form->{id}, dbh => $dbh);
+
my $rc = 1;
if (!$provided_dbh) {
$dbh->commit();
do_query($form, $dbh, $query, (values %$row));
}
+ map { IO->set_datepaid(table => 'ap', id => $_, dbh => $dbh) } ($id, $new_id);
+
$dbh->commit;
$main::lxdebug->leave_sub();
use Data::Dumper;
use SL::DBUtils;
+use SL::IO;
use SL::MoreCommon;
use strict;
($null, $form->{department_id}) = split(/--/, $form->{department});
$form->{department_id} *= 1;
- # record last payment date in ar table
- $form->{datepaid} ||= $form->{transdate} ;
- my $datepaid = ($form->{paid} != 0) ? $form->{datepaid} : undef;
-
# amount for AR account
$form->{receivables} = $form->round_amount($form->{amount}, 2) * -1;
$query =
qq|UPDATE ar set
invnumber = ?, ordnumber = ?, transdate = ?, customer_id = ?,
- taxincluded = ?, amount = ?, duedate = ?, paid = ?, datepaid = ?,
+ taxincluded = ?, amount = ?, duedate = ?, paid = ?,
netamount = ?, curr = ?, notes = ?, department_id = ?,
employee_id = ?, storno = ?, storno_id = ?
WHERE id = ?|;
my @values = ($form->{invnumber}, $form->{ordnumber}, conv_date($form->{transdate}), conv_i($form->{customer_id}), $form->{taxincluded} ? 't' : 'f', $form->{amount},
- conv_date($form->{duedate}), $form->{paid}, conv_date($datepaid), $form->{netamount}, $form->{currency}, $form->{notes}, conv_i($form->{department_id}),
+ conv_date($form->{duedate}), $form->{paid}, $form->{netamount}, $form->{currency}, $form->{notes}, conv_i($form->{department_id}),
conv_i($form->{employee_id}), $form->{storno} ? 't' : 'f', $form->{storno_id}, conv_i($form->{id}));
do_query($form, $dbh, $query, @values);
}
}
+ IO->set_datepaid(table => 'ar', id => $form->{id}, dbh => $dbh);
+
my $rc = 1;
if (!$provided_dbh) {
$rc = $dbh->commit();
do_query($form, $dbh, $query, (values %$row));
}
+ map { IO->set_datepaid(table => 'ap', id => $_, dbh => $dbh) } ($id, $new_id);
+
$dbh->commit;
$main::lxdebug->leave_sub();
my $table = $params{vc} eq 'customer' ? 'customer' : 'vendor';
my @ids = ref $params{id} eq 'ARRAY' ? @{ $params{id} } : ($params{id});
- my $placeholders = ('?') x scalar @ids;
+ my $placeholders = join ", ", ('?') x scalar @ids;
my $query = qq|SELECT id, name, account_number, bank, bank_code, iban, bic
FROM ${table}
WHERE id IN (${placeholders})|;
qq|SELECT a.id, a.ordnumber, a.invoice, a.transdate, a.invnumber, a.amount,
ct.name AS customername, ct.id AS customer_id, a.duedate, da.fee,
da.interest, dn.dunning_description, da.transdate AS dunning_date,
- da.duedate AS dunning_duedate, da.dunning_id, da.dunning_config_id
+ da.duedate AS dunning_duedate, da.dunning_id, da.dunning_config_id,
+ e2.name AS salesman
FROM ar a
- JOIN customer ct ON (a.customer_id = ct.id), dunning da
+ JOIN customer ct ON (a.customer_id = ct.id)
+ LEFT JOIN employee e2 ON (a.salesman_id = e2.id), dunning da
LEFT JOIN dunning_config dn ON (da.dunning_config_id = dn.id)
$where
ORDER BY $sortorder|;
sub header {
$main::lxdebug->enter_sub();
+ # extra code ist currently only used by menuv3 and menuv4 to set their css.
+ # it is strongly deprecated, and will be changed in a future version.
my ($self, $extra_code) = @_;
if ($self->{header}) {
ORDER BY description|;
$self->{all_departments} = selectall_hashref_query($self, $dbh, $query);
- delete($self->{all_departments}) unless (@{ $self->{all_departments} });
+ delete($self->{all_departments}) unless (@{ $self->{all_departments} || [] });
$main::lxdebug->leave_sub();
}
package IO;
+use List::Util qw(first);
+use List::MoreUtils qw(any);
+
use SL::DBUtils;
use strict;
}
+sub set_datepaid {
+ $main::lxdebug->enter_sub();
+
+ my $self = shift;
+ my %params = @_;
+
+ Common::check_params(\%params, qw(id table));
+
+ my $myconfig = \%main::myconfig;
+ my $form = $main::form;
+
+ my $dbh = $params{dbh} || $form->get_standard_dbh($myconfig);
+ my $id = conv_i($params{id});
+ my $table = (any { $_ eq $params{table} } qw(ar ap gl)) ? $params{table} : 'ar';
+
+ my ($curr_datepaid, $curr_paid) = selectfirst_array_query($form, $dbh, qq|SELECT datepaid, paid FROM $table WHERE id = ?|, $id);
+
+ my $query = <<SQL;
+ SELECT MAX(at.transdate)
+ FROM acc_trans at
+ LEFT JOIN chart c ON (at.chart_id = c.id)
+ WHERE (at.trans_id = ?)
+ AND (c.link LIKE '%paid%')
+SQL
+
+ my ($max_acc_trans_date) = selectfirst_array_query($form, $dbh, $query, $id);
+
+ if ($max_acc_trans_date && ($max_acc_trans_date ne $curr_datepaid)) {
+ # 1. Fall: Es gab mindestens eine Zahlung, und das Datum der Zahlung entspricht nicht
+ # dem vermerkten Zahlungsdatum.
+ do_query($form, $dbh, qq|UPDATE $table SET datepaid = ? WHERE id = ?|, $max_acc_trans_date, $id);
+
+ } elsif (!$max_acc_trans_date && ($curr_paid * 1)) {
+ # 2. Fall: Es gab keine Zahlung, aber paid ist nicht 0. Das ist z.B. der Fall, wenn
+ # die Funktion "als bezahlt buchen" verwendet oder wenn ein Beleg storniert wird.
+ # In diesem Fall das letzte Modifikationsdatum als Bezahldatum nehmen, oder aber das
+ # Erstelldatum, wenn keine Modifikation erfolgt ist (bei Stornos z.B.).
+ do_query($form, $dbh, qq|UPDATE $table SET datepaid = COALESCE(mtime::date, itime::date) WHERE id = ?|, $id);
+ }
+
+ $dbh->commit() unless $params{dbh};
+
+ $main::lxdebug->leave_sub();
+}
+
+
1;
use SL::DBUtils;
use SL::DO;
use SL::GenericTranslations;
+use SL::IO;
use SL::MoreCommon;
use List::Util qw(min);
# ansonsten stolpert man immer wieder viermal statt einmal heftig
# und auch das undo discount formatting ist nicht besonders wartungsfreundlich
- # keep entered selling price
- $fxsellprice = $form->parse_amount($myconfig, $form->{"sellprice_$i"});
-
# keine ahnung wofür das in IS.pm gemacht wird:
# my ($dec) = ($fxsellprice =~ /\.(\d+)/);
# $dec = length $dec;
}
}
+ IO->set_datepaid(table => 'ap', id => $form->{id}, dbh => $dbh);
+
if ($payments_only) {
- $query = qq|UPDATE ap SET paid = ?, datepaid = ? WHERE id = ?|;
- do_query($form, $dbh, $query, $form->{paid}, $form->{paid} ? conv_date($form->{datepaid}) : undef, conv_i($form->{id}));
+ $query = qq|UPDATE ap SET paid = ? WHERE id = ?|;
+ do_query($form, $dbh, $query, $form->{paid}, conv_i($form->{id}));
if (!$provided_dbh) {
$dbh->commit();
$query = qq|UPDATE ap SET
invnumber = ?, ordnumber = ?, quonumber = ?, transdate = ?,
orddate = ?, quodate = ?, vendor_id = ?, amount = ?,
- netamount = ?, paid = ?, duedate = ?, datepaid = ?,
+ netamount = ?, paid = ?, duedate = ?,
invoice = ?, taxzone_id = ?, notes = ?, taxincluded = ?,
intnotes = ?, curr = ?, storno_id = ?, storno = ?,
cp_id = ?, employee_id = ?, department_id = ?,
@values = (
$form->{invnumber}, $form->{ordnumber}, $form->{quonumber}, conv_date($form->{invdate}),
conv_date($form->{orddate}), conv_date($form->{quodate}), conv_i($form->{vendor_id}), $amount,
- $netamount, $form->{paid}, conv_date($form->{duedate}), $form->{paid} ? conv_date($form->{datepaid}) : undef,
+ $netamount, $form->{paid}, conv_date($form->{duedate}),
'1', $taxzone_id, $form->{notes}, $form->{taxincluded} ? 't' : 'f',
$form->{intnotes}, $form->{currency}, conv_i($form->{storno_id}), $form->{storno} ? 't' : 'f',
conv_i($form->{cp_id}), conv_i($form->{employee_id}), conv_i($form->{department_id}),
use SL::GenericTranslations;
use SL::MoreCommon;
use SL::IC;
+use SL::IO;
use Data::Dumper;
use strict;
$form->{marge_total} *= -1;
}
+ IO->set_datepaid(table => 'ar', id => $form->{id}, dbh => $dbh);
+
if ($payments_only) {
- $query = qq|UPDATE ar SET paid = ?, datepaid = ? WHERE id = ?|;
- do_query($form, $dbh, $query, $form->{paid}, $form->{paid} ? conv_date($form->{datepaid}) : undef, conv_i($form->{id}));
+ $query = qq|UPDATE ar SET paid = ? WHERE id = ?|;
+ do_query($form, $dbh, $query, $form->{paid}, conv_i($form->{id}));
if (!$provided_dbh) {
$dbh->commit();
$query = qq|UPDATE ar set
invnumber = ?, ordnumber = ?, quonumber = ?, cusordnumber = ?,
transdate = ?, orddate = ?, quodate = ?, customer_id = ?,
- amount = ?, netamount = ?, paid = ?, datepaid = ?,
+ amount = ?, netamount = ?, paid = ?,
duedate = ?, deliverydate = ?, invoice = ?, shippingpoint = ?,
shipvia = ?, terms = ?, notes = ?, intnotes = ?,
curr = ?, department_id = ?, payment_id = ?, taxincluded = ?,
cp_id = ?, marge_total = ?, marge_percent = ?,
globalproject_id = ?, delivery_customer_id = ?,
transaction_description = ?, delivery_vendor_id = ?,
- donumber = ?
+ donumber = ?
WHERE id = ?|;
@values = ( $form->{"invnumber"}, $form->{"ordnumber"}, $form->{"quonumber"}, $form->{"cusordnumber"},
conv_date($form->{"invdate"}), conv_date($form->{"orddate"}), conv_date($form->{"quodate"}), conv_i($form->{"customer_id"}),
- $amount, $netamount, $form->{"paid"}, conv_date($form->{"datepaid"}),
+ $amount, $netamount, $form->{"paid"},
conv_date($form->{"duedate"}), conv_date($form->{"deliverydate"}), '1', $form->{"shippingpoint"},
$form->{"shipvia"}, conv_i($form->{"terms"}), $form->{"notes"}, $form->{"intnotes"},
$form->{"currency"}, conv_i($form->{"department_id"}), conv_i($form->{"payment_id"}), $form->{"taxincluded"} ? 't' : 'f',
conv_i($form->{"cp_id"}), 1 * $form->{marge_total} , 1 * $form->{marge_percent},
conv_i($form->{"globalproject_id"}), conv_i($form->{"delivery_customer_id"}),
$form->{transaction_description}, conv_i($form->{"delivery_vendor_id"}),
- $form->{"donumber"}, #das entsprechende feld lieferscheinnummer aus der html-form 12.02.09 jb
+ $form->{"donumber"}, #das entsprechende feld lieferscheinnummer aus der html-form 12.02.09 jb
conv_i($form->{"id"}));
do_query($form, $dbh, $query, @values);
my ($self, $myconfig, $form, $item) = @_;
- my $module = $form->{script};
- my $action = "section_menu";
- my $target = "";
+ my $module = $self->{$item}{module} || $form->{script};
+ my $action = $self->{$item}{action} || "section_menu";
+ my $target = $self->{$item}{target} || "";
- if ($self->{$item}{module}) {
- $module = $self->{$item}{module};
- }
- if ($self->{$item}{action}) {
- $action = $self->{$item}{action};
- }
- if ($self->{$item}{target}) {
- $target = $self->{$item}{target};
- }
+ my $level = $form->escape($item);
- my $level = $form->escape($item);
+ my $style = 'style="vertical-align:top"';
+ my $target_token = ($target)
+ ? "target='$target'" : '';
- my $str = qq|<a style="vertical-align:top" href=$module?action=$action&level=$level|;
+ my $href = ($self->{$item}{href})
+ ? $form->escape($self->{$item}{href})
+ : "$module?action=$action&level=$level";
- my @vars = qw(module action target href);
-
- if ($self->{$item}{href}) {
- $str = qq|<a href=$self->{$item}{href}|;
- @vars = qw(module target href);
- }
+ my @vars = ($self->{$item}{href})
+ ? qw(module target href)
+ : qw(module action target href);
map { delete $self->{$item}{$_} } @vars;
# add other params
foreach my $key (keys %{ $self->{$item} }) {
- $str .= "&" . $form->escape($key, 1) . "=";
+ $href .= "&" . $form->escape($key, 1) . "=";
my ($value, $conf) = split(/=/, $self->{$item}{$key}, 2);
$value = $myconfig->{$value} . "/$conf" if ($conf);
- $str .= $form->escape($value, 1);
- }
-
- if ($target) {
- $str .= qq| target=$target|;
+ $href .= $form->escape($value, 1);
}
- $str .= ">";
+ my $str = "<a href='$href' $target_token $style>";
$main::lxdebug->leave_sub();
my @ary = scalar @_ > 1 ? @_ : ref $_[0] eq 'ARRAY' ? @{ $_[0] } : (@_);
return wantarray ? @ary : scalar @ary;
}
-+
1;
}
1;
+
+__END__
+
+=head1 NAME
+
+SL::RecordLinks - Verlinkung von Lx-Office Objekten.
+
+=head1 SYNOPSIS
+
+ use SL::RecordLinks;
+
+ my @links = RecordLinks->get_links(
+ from_table => 'ar',
+ from_id => 2,
+ to_table => 'oe',
+ );
+ my @links = RecordLinks->get_links_via(
+ from_table => 'oe',
+ to_id => '14',
+ via => [
+ { id => 12 },
+ { id => 13},
+ ],
+ );
+
+ RecordLinks->create_links(
+ mode => 'ids',
+ from_table => 'ar',
+ from_id => 1,
+ to_table => 'oe',
+ to_ids => [4, 6, 9],
+ )
+ RecordLinks->create_links(@links);
+
+ delete
+
+=head1 DESCRIPTION
+
+=over 4
+
+Transitive RecordLinks mit get_links_via.
+
+get_links_via erwartet den zusätzlichen parameter via. via ist ein
+hashref mit den jeweils optionalen Einträgen table und id, die sich
+genauso verhalten wie die from/to_table/id werte der get_links funktion.
+
+Alternativ kann via auch ein Array dieser Hashes sein:
+
+ get_links_via(
+ from_table => 'oe',
+ from_id => 1,
+ to_table => 'ar',
+ via => {
+ table => 'delivery_orders'
+ },
+ )
+
+ get_links_via(
+ from_table => 'oe',
+ to_id => '14',
+ via => [
+ { id => 12 },
+ { id => 13},
+ ],
+ )
+
+Die Einträge in einem via-Array werden exakt in dieser Reihenfolge
+benutzt und sind nicht optional. Da obige Beispiel würde also die
+Verknüpfung:
+
+ oe:11 -> ar:12 -> is:13 -> do:14
+
+finden, nicht aber:
+
+ oe:11 -> ar:13 -> do:14
+
+=back
+
+=cut
map { $form->{selectcurrency} .= "<option>$_\n" } @curr;
# vendors
- if (@{ $form->{all_vendor} }) {
+ if (@{ $form->{all_vendor} || [] }) {
$form->{vendor} = qq|$form->{vendor}--$form->{vendor_id}|;
map { $form->{selectvendor} .= "<option>$_->{name}--$_->{id}\n" }
(@{ $form->{all_vendor} });
}
# departments
- if (@{ $form->{all_departments} }) {
+ if (@{ $form->{all_departments} || [] }) {
$form->{selectdepartment} = "<option>\n";
$form->{department} = "$form->{department}--$form->{department_id}";
map {
$form->{selectdepartment} .=
"<option>$_->{description}--$_->{id}\n"
- } (@{ $form->{all_departments} });
+ } (@{ $form->{all_departments} || [] });
}
$form->{employee} = "$form->{employee}--$form->{employee_id}";
my ($debitaccno, $debittaxkey) = split /--/, $form->{AP_amountselected};
my ($taxkey, $NULL) = split /--/, $form->{taxchartselected};
my ($payablesaccno, $payablestaxkey) = split /--/, $form->{APselected};
- $form->{AP}{amount_1} = $debitaccno;
- $form->{AP}{payables} = $payablesaccno;
+ $form->{AP_amount_1} = $debitaccno;
+ $form->{AP_payables} = $payablesaccno;
$form->{taxkey} = $taxkey;
$form->{storno} = 0;
$form->all_vc(\%myconfig, "vendor", "AP");
my $vendor;
- if (@{ $form->{all_vendor} }) {
+ if (@{ $form->{all_vendor} || [] }) {
map { $vendor .= "<option>$_->{name}--$_->{id}\n" }
@{ $form->{all_vendor} };
$vendor = qq|<select name=vendor><option>\n$vendor\n</select>|;
}
# departments
- if (@{ $form->{all_departments} }) {
+ if (@{ $form->{all_departments} || [] }) {
$form->{selectdepartment} = "<option>\n";
map {
$form->{selectdepartment} .=
"<option>$_->{description}--$_->{id}\n"
- } (@{ $form->{all_departments} });
+ } (@{ $form->{all_departments} || [] });
}
my $department = qq|
map { $form->{selectcurrency} .= "<option>$_\n" } @curr;
# customers
- if (@{ $form->{all_customer} }) {
+ if (@{ $form->{all_customer} || [] }) {
$form->{customer} = "$form->{customer}--$form->{customer_id}";
map { $form->{selectcustomer} .= "<option>$_->{name}--$_->{id}\n" }
(@{ $form->{all_customer} });
}
# departments
- if (@{ $form->{all_departments} }) {
+ if (@{ $form->{all_departments} || [] }) {
$form->{selectdepartment} = "<option>\n";
$form->{department} = "$form->{department}--$form->{department_id}";
map {
$form->{selectdepartment} .=
"<option>$_->{description}--$_->{id}\n"
- } (@{ $form->{all_departments} });
+ } (@{ $form->{all_departments} || [] });
}
$form->{employee} = "$form->{employee}--$form->{employee_id}";
# sales staff
- if (@{ $form->{all_employees} }) {
+ if (@{ $form->{all_employees} || [] }) {
$form->{selectemployee} = "";
map { $form->{selectemployee} .= "<option>$_->{name}--$_->{id}\n" }
- (@{ $form->{all_employees} });
+ (@{ $form->{all_employees} || [] });
}
# build the popup menus
# setup customer selection
$form->all_vc(\%myconfig, "customer", "AR");
- if (@{ $form->{all_customer} }) {
+ if (@{ $form->{all_customer} || [] }) {
map { $customer .= "<option>$_->{name}--$_->{id}\n" }
@{ $form->{all_customer} };
$customer = qq|<select name=customer><option>\n$customer</select>|;
}
# departments
- if (@{ $form->{all_departments} }) {
+ if (@{ $form->{all_departments} || [] }) {
$form->{selectdepartment} = "<option>\n";
map {
$form->{selectdepartment} .=
"<option>$_->{description}--$_->{id}\n"
- } (@{ $form->{all_departments} });
+ } (@{ $form->{all_departments} || [] });
}
$department = qq|
# setup customer/vendor selection
BP->get_vc(\%myconfig, \%$form);
- if (@{ $form->{"all_$form->{vc}"} }) {
+ if (@{ $form->{"all_$form->{vc}"} || [] }) {
map { $name .= "<option>$_->{name}--$_->{id}\n" }
@{ $form->{"all_$form->{vc}"} };
$name = qq|<select name=$form->{vc}><option>\n$name</select>|;
# get departments
$form->all_departments(\%myconfig);
- if (@{ $form->{all_departments} }) {
+ if (@{ $form->{all_departments} || [] }) {
$form->{selectdepartment} = "<option>\n";
map {
$form->{selectdepartment} .=
"<option>$_->{description}--$_->{id}\n"
- } (@{ $form->{all_departments} });
+ } (@{ $form->{all_departments} || [] });
}
my $department = qq|
if($form->{mark_as_paid}) {
my $dbh ||= $form->get_standard_dbh($myconfig);
- my $query = qq|UPDATE $db_name SET paid = amount WHERE id = ?|;
+ my $query = qq|UPDATE $db_name SET paid = amount, datepaid = current_date WHERE id = ?|;
do_query($form, $dbh, $query, $form->{id});
$dbh->commit();
$form->redirect($locale->text("Marked as paid"));
}
# departments
- if (@{ $form->{all_departments} }) {
+ if (@{ $form->{all_departments} || [] }) {
$form->{selectdepartment} = "<option>\n";
$form->{department} = "$form->{department}--$form->{department_id}";
map {
$form->{selectdepartment} .=
"<option>$_->{description}--$_->{id}\n"
- } (@{ $form->{all_departments} });
+ } (@{ $form->{all_departments} || [] });
}
CP->paymentaccounts(\%myconfig, \%$form);
<td>
<table width=100%>
<tr valign=top>
- <td>
- <table>
- <tr>
- <td align=right>
- <input name=all_vc type=checkbox style=checkbox value=Y $allvc>
- <input type=hidden name="oldall_vc" value="$form->{all_vc}"></td>
- <th align=left>| . $locale->text('All') . qq|</th>
- </tr>
- <tr>
- <th align=right>$vclabel</th>
- <td>$vc</td>
- <input type=hidden name="select$form->{vc}" value="$form->{"select$form->{vc}"}">
- <input type=hidden name="$form->{vc}_id" value=$form->{"$form->{vc}_id"}>
- <input type=hidden name="old$form->{vc}" value="$form->{"old$form->{vc}"}">
- </tr>
- <tr valign=top>
- <th align=right nowrap>| . $locale->text('Address') . qq|</th>
- <td colspan=2>
- <table>
- <tr>
- <td>$form->{street}</td>
- </tr>
- <tr>
- <td>$form->{zipcode}</td>
- </tr>
- <tr>
- <td>$form->{city}</td>
- </tr>
- <tr>
- <td>$form->{country}</td>
- </tr>
- </table>
- </td>
- <input type=hidden name=street value="$form->{street}">
- <input type=hidden name=zipcode value="$form->{zipcode}">
- <input type=hidden name=city value="$form->{city}">
- <input type=hidden name=country value="$form->{country}">
- </tr>
- <tr>
- <th align=right>| . $locale->text('Memo') . qq|</th>
- <td colspan=2><input name="memo" size=30 value="$form->{memo}"></td>
- </tr>
- </table>
- </td>
- <td align=right>
- <table>
- $department
- <tr>
- <th align=right nowrap>| . $locale->text('Account') . qq|</th>
- <td colspan=3><select name=account>$form->{selectaccount}</select>
- <input type=hidden name=selectaccount value="$form->{selectaccount}">
- </td>
- </tr>
- <tr>
- <th align=right nowrap>| . $locale->text('Date') . qq|</th>
+ <td>
+ <table>
+ <tr>
+ <td align=right>
+ <input name=all_vc type=checkbox style=checkbox value=Y $allvc>
+ <input type=hidden name="oldall_vc" value="$form->{all_vc}"></td>
+ <th align=left>| . $locale->text('All') . qq|</th>
+ </tr>
+ <tr>
+ <th align=right>$vclabel</th>
+ <td>$vc</td>
+ <input type=hidden name="select$form->{vc}" value="| . H($form->{"select$form->{vc}"}) . qq|">
+ <input type=hidden name="$form->{vc}_id" value="| . H($form->{"$form->{vc}_id"}) . qq|">
+ <input type=hidden name="old$form->{vc}" value="| . H($form->{"old$form->{vc}"}) . qq|">
+ </tr>
+ <tr valign=top>
+ <th align=right nowrap>| . $locale->text('Address') . qq|</th>
+ <td colspan=2>
+ <table>
+ <tr>
+ <td>$form->{street}</td>
+ </tr>
+ <tr>
+ <td>$form->{zipcode}</td>
+ </tr>
+ <tr>
+ <td>$form->{city}</td>
+ </tr>
+ <tr>
+ <td>$form->{country}</td>
+ </tr>
+ </table>
+ </td>
+ <input type=hidden name=street value="$form->{street}">
+ <input type=hidden name=zipcode value="$form->{zipcode}">
+ <input type=hidden name=city value="$form->{city}">
+ <input type=hidden name=country value="$form->{country}">
+ </tr>
+ <tr>
+ <th align=right>| . $locale->text('Memo') . qq|</th>
+ <td colspan=2><input name="memo" size=30 value="$form->{memo}"></td>
+ </tr>
+ </table>
+ </td>
+ <td align=right>
+ <table>
+ $department
+ <tr>
+ <th align=right nowrap>| . $locale->text('Account') . qq|</th>
+ <td colspan=3><select name=account>$form->{selectaccount}</select>
+ <input type=hidden name=selectaccount value="$form->{selectaccount}">
+ </td>
+ </tr>
+ <tr>
+ <th align=right nowrap>| . $locale->text('Date') . qq|</th>
$button1
- </tr>
- <tr>
- <th align=right nowrap>| . $locale->text('Currency') . qq|</th>
- <td><select name=currency>$form->{selectcurrency}</select></td>
- <input type=hidden name=selectcurrency value="$form->{selectcurrency}">
- <input type=hidden name=oldcurrency value=$form->{oldcurrency}>
- </tr>
- $exchangerate
- <tr>
- <th align=right nowrap>| . $locale->text('Source') . qq|</th>
- <td colspan=3><input name=source value="$form->{source}" size=10></td>
- </tr>
- <tr>
- <th align="right" nowrap>| . $locale->text('Amount') . qq|</th>
- <td colspan="3"><input name="amount" size="10" value="|
+ </tr>
+ <tr>
+ <th align=right nowrap>| . $locale->text('Currency') . qq|</th>
+ <td><select name=currency>$form->{selectcurrency}</select></td>
+ <input type=hidden name=selectcurrency value="$form->{selectcurrency}">
+ <input type=hidden name=oldcurrency value=$form->{oldcurrency}>
+ </tr>
+ $exchangerate
+ <tr>
+ <th align=right nowrap>| . $locale->text('Source') . qq|</th>
+ <td colspan=3><input name=source value="$form->{source}" size=10></td>
+ </tr>
+ <tr>
+ <th align="right" nowrap>| . $locale->text('Amount') . qq|</th>
+ <td colspan="3"><input name="amount" size="10" value="|
. $form->format_amount(\%myconfig, $form->{amount}, 2) . qq|" onBlur=\"check_right_number_format(this)\"></td>
- </tr>
- </table>
- </td>
- </tr>
+ </tr>
+ </table>
+ </td>
+ </tr>
</table>
</td>
</tr>
}
# Modified by J.Zach, see abovev
- $amount += $form->{"paid_$i"};
+ $amount += $form->{"paid_$i"};
} else {
$form->{"paid_$i"} = "";
}
# Line added by J.Zach, see above
- $form->{amount}=$amount;
+ $form->{amount}=$amount;
&form_header;
&list_invoices;
$form->{SHOW_CUSTOMER_SELECTION} = $form->{all_customer} && scalar @{ $form->{all_customer} };
$form->{SHOW_DUNNING_LEVEL_SELECTION} = $form->{DUNNING} && scalar @{ $form->{DUNNING} };
- $form->{SHOW_DEPARTMENT_SELECTION} = $form->{all_departments} && scalar @{ $form->{all_departments} };
+ $form->{SHOW_DEPARTMENT_SELECTION} = $form->{all_departments} && scalar @{ $form->{all_departments} || [] };
$form->{title} = $locale->text('Start Dunning Process');
$form->{jsscript} = 1;
$main::auth->assert('dunning_edit');
my @filter_field_list = qw(customer_id customer dunning_level department_id invnumber ordnumber
- transdatefrom transdateto dunningfrom dunningto notes showold);
+ transdatefrom transdateto dunningfrom dunningto notes showold salesman);
report_generator_set_default_sort('customername', 1);
'interest' => { 'text' => $locale->text('Interest') },
);
+ if ($form->{l_salesman}) {
+ # Show salesman column
+ $column_defs{'salesman'} = ( { 'text' => $locale->text('Salesperson') } );
+ }
+
$report->set_columns(%column_defs);
$report->set_column_order(qw(checkbox dunning_description customername invnumber transdate
- duedate amount dunning_date dunning_duedate fee interest));
+ duedate amount dunning_date dunning_duedate fee interest salesman));
$report->set_sort_indicator($form->{sort}, $form->{sortdir});
my $edit_url = build_std_url('script=is.pl', 'action=edit', 'callback') . '&id=';
my $print_url = build_std_url('action=print_dunning', 'format=pdf', 'media=screen') . '&dunning_id=';
my $sort_url = build_std_url('action=show_dunning', grep { $form->{$_} } @filter_field_list);
- foreach my $name (qw(dunning_description customername invnumber transdate duedate dunning_date dunning_duedate)) {
+ foreach my $name (qw(dunning_description customername invnumber transdate duedate dunning_date dunning_duedate salesman)) {
my $sortdir = $form->{sort} eq $name ? 1 - $form->{sortdir} : $form->{sortdir};
$column_defs{$name}->{link} = $sort_url . "&sort=$name&sortdir=$sortdir";
}
- my %alignment = map { $_ => 'right' } qw(transdate duedate amount dunning_date dunning_duedate fee interest);
+ my %alignment = map { $_ => 'right' } qw(transdate duedate amount dunning_date dunning_duedate fee interest salesman);
my ($current_dunning_rows, $previous_dunning_id, $first_row_for_dunning);
$form->{type} = "invoice";
# locale messages
- $locale = new Locale "$myconfig{countrycode}", "$script";
+ $main::locale = new Locale "$myconfig{countrycode}", "$script";
+ $locale = $main::locale;
require "bin/mozilla/$form->{script}";
# departments
$form->all_departments(\%myconfig);
- if (@{ $form->{all_departments} }) {
+ if (@{ $form->{all_departments} || [] }) {
$form->{selectdepartment} = "<option>\n";
map {
$form->{selectdepartment} .=
"<option>$_->{description}--$_->{id}\n"
- } (@{ $form->{all_departments} });
+ } (@{ $form->{all_departments} || [] });
}
$form->{show_details} = $myconfig{show_form_details} unless defined $form->{show_details};
# departments
$form->all_departments(\%myconfig);
- if (@{ $form->{all_departments} }) {
+ if (@{ $form->{all_departments} || [] }) {
$form->{selectdepartment} = "<option>\n";
map {
$form->{selectdepartment} .=
"<option>$_->{description}--$_->{id}\n"
- } (@{ $form->{all_departments} });
+ } (@{ $form->{all_departments} || [] });
}
my $i = 1;
$form->all_departments(\%myconfig);
# departments
- if (@{ $form->{all_departments} }) {
+ if (@{ $form->{all_departments} || [] }) {
$form->{selectdepartment} = "<option>\n";
map {
$form->{selectdepartment} .=
"<option>$_->{description}--$_->{id}\n"
- } (@{ $form->{all_departments} });
+ } (@{ $form->{all_departments} || [] });
}
my $department = qq|
map {
$form->{selectdepartment} .=
"<option>$_->{description}--$_->{id}\n"
- } (@{ $form->{all_departments} });
+ } (@{ $form->{all_departments} || [] });
}
# forex
# expand menu
if ($zeige) {
print
- qq|<tr><td valign=bottom><b>$spacer<img src="image/unterpunkt.png">$label</b></td></tr>\n|;
+ qq|<tr><td style='vertical-align:bottom'><b>$spacer<img src="image/unterpunkt.png">$label</b></td></tr>\n|;
}
# remove same level items
$form->{employee} = "$form->{employee}--$form->{employee_id}";
# build vendor/customer drop down comatibility... don't ask
- if (@{ $form->{"all_$form->{vc}"} }) {
+ if (@{ $form->{"all_$form->{vc}"} || [] }) {
$form->{"select$form->{vc}"} = 1;
$form->{$form->{vc}} = qq|$form->{$form->{vc}}--$form->{"$form->{vc}_id"}|;
}
print_options => print_options(inline => 1),
label_edit => $locale->text("Edit the $form->{type}"),
label_workflow => $locale->text("Workflow $form->{type}"),
+ is_sales => scalar ($form->{type} =~ /^sales_/), # these vars are exported, so that the template
+ is_order => scalar ($form->{type} =~ /_order$/), # may determine what to show
+ is_sales_quo => scalar ($form->{type} =~ /sales_quotation$/),
+ is_req_quo => scalar ($form->{type} =~ /request_quotation$/),
+ is_sales_ord => scalar ($form->{type} =~ /sales_order$/),
+ is_pur_ord => scalar ($form->{type} =~ /purchase_order$/),
});
$main::lxdebug->leave_sub();
my @hidden_variables = map { "l_${_}" } @columns;
push @hidden_variables, "l_subtotal", $form->{vc}, qw(l_closed l_notdelivered open closed delivered notdelivered ordnumber quonumber
transaction_description transdatefrom transdateto type vc employee_id salesman_id
- reqdatefrom reqdateto);
+ reqdatefrom reqdateto projectnumber);
my $href = build_std_url('action=orders', grep { $form->{$_} } @hidden_variables);
$form->{type} = "invoice";
# locale messages
- $locale = new Locale "$myconfig{countrycode}", "$script";
+ $main::locale = new Locale "$myconfig{countrycode}", "$script";
+ $locale = $main::locale;
require "bin/mozilla/$form->{script}";
# get departments
$form->all_departments(\%myconfig);
- if (@{ $form->{all_departments} }) {
+ if (@{ $form->{all_departments} || [] }) {
$form->{selectdepartment} = "<option>\n";
- map { $form->{selectdepartment} .= "<option>$_->{description}--$_->{id}\n" } @{ $form->{all_departments} };
+ map { $form->{selectdepartment} .= "<option>$_->{description}--$_->{id}\n" } @{ $form->{all_departments} || [] };
}
my $department = qq|
# Veränderungen von Lx-Office ERP #
###################################
+2009-11-5 - unstable stand release-2.6.0-340-g9e15903
+
+ Größere neue Features:
+
+ - SEPA Export
+
+ Lx-Office unterstützt nun die elektronische Überweisung im SEPA Format.
+ Eine genaue Anleitung und Feature Beschreibung dazu gibt es in den
+ Releasenotes.
+
+ - Secure Cookies.
+
+ Diese Option ist standardmäßig akiviert, und sollte moderne Browser
+ anweisen, das Lx-Office Cookie nur an per https gesicherte Webseiten
+ herauszugeben. Dadurch wird die Identifikationssicherheit erhöht.
+
+ - Benutzerdefinierte Variablen in Artikelstammdaten.
+
+ Zusättzlich zu Aufträgen, Lieferscheinen und Rechnungen sind
+ benutzerdefinierte Vriabeln jetzt auch in Waren, Dienstleistungen
+ und Erzeugnissen verfügbar. Diese werden, sofern als solche markiert, auch
+ in Belegen in den Artiekln mit angezeigt, und werden wie Beschreibung und
+ Preis überlagert. In der Artikelsuche sind sie durchsuchbar.
+
+
+ Kleinere neue Features und Detailverbesserungen:
+
+ - Das alte Javascriptmenü funktioniert jetzt wieder.
+ - Der Parser für CGI Variablen wurde überarbeitet.
+ - MIME Types für PDF-Anhänge aus OpenDocument Vorlagen werden nun korrekt
+ gesetzt.
+ - Wenn Javascript ausgeschaltet ist, wird jetzt eine Warnung auf dem
+ Startbildschirm angezeigt.
+ - Die Artikelmaske ist jetzt mit Tabs aufgeräumt.
+ - Einige alte Dateien aus der SQL Ledger Basis wurden entfernt.
+ - Die Darstellung auf Browsern der KHTML Engine (z.B. Konqueror) wurde
+ verbessert.
+ - Die Darstellung des CSS Menüs wurde leicht verbessert.
+ - Die Funktionalität der Warensuche wurde deutlich erweitert, vorallem die
+ Suche nach Waren, die in Belegen verwendet werden.
+ - Charset Konvertierungen werden jetzt nur dann durchgeführt, wenn sich die
+ Charsets auch wirklich unterscheiden.
+ - Bei Lieferschein zu Rechnung Konvertierung werden jetzt die Lieferdaten in
+ die Artikelzeilen übernommen.
+ - Bei 'als neu speichern' bei Aufträgen wurden einige Felder nicht korrekt
+ gesetzt.
+ - Standardgewichtseinheit wird im unter den Stadardeinstellungen jetzt als
+ Auswahl präsentiert.
+ - Workflowaktionen in Belegen setzen jetzt den Bearbeiter korrekt.
+ - Dislogbuchen geht nicht mehr auf Überschriftskonten.
+ - Artikel haben jetzt ein Attribut, das anziegt ob sie eine Seriennummer
+ haben.
+ - Benutzerdefinierte Variablen können jetzte als ungültig markiert werden, und
+ tauchen dann für diesen Artikel nicht mehr in Belegen auf.
+ - Die Sprache American English wurde entfernt.
+ - Die Sprache British English wurde in English umbenannt.
+ - Lieferscheine werden jetzt auch im WebDAV gespeichert.
+ - In allen Masken wird bei Erneuern in der gleichen Maske jetzt der Fokus
+ beibehalten.
+ - Gewinn und Verlustrechnungen berücksichtigt jetzt partielle Zahlungen.
+ - Die Detailansicht in Belegen wird jetzt über Javascript getriggert und
+ benötigt keinen Seitenneuaufbau mehr.
+ - Aufträge behalten ihren Fokus jetzt explizit auch beim Speichern. Dadurch
+ ist es möglich während des bearbeitens eines Auftrags zwischenzuspeichern,
+ ohne den Arbeitsfluß zu unterbrechen.
+
+
+
+ API Änderungen:
+
+ - cp_greeting heisst jetzt cp_gender und ist auf die flags 'm' und 'f'
+ beschränkt.
+ - Mit SL::GenericTranslations ist ein Modul dazugekommen um beliebige Elemente
+ zu übersetzen.
+ - Die Syntax für das <%if ...%> Konstrukt in Templates wurde deutlich
+ erweitert (Dokumentation in doc/dokumentenvorlage-und-variablen.html).
+ - Das Mahnsystem exportiert jetzt mehr Felder an die Templates.
+ - SL::RecordLinks haben jetzt eine transitive Suchfunktion: get_links_via.
+ Siehe perldoc SL::RecordLinks
+ - SL::MoreCommon exportiert jetzt einige nützliche
+ Arraymanipulationsfunktionen die an Ruby angelehnt sind.
+ - SL::DBUtils hat jetzt eine Funktion zum überprüfen ob eine Tablelle
+ existiert, und einen Wrapper für große tokenbasierte Selects.
+ - SL::OE kennt jetzt die Funktion retrieve_simple, die einen Auftrag nach id
+ lädt, ohne die kompletten Kontextinformationen von retrieve zu laden.
+ - login.pl unterstützt jetzt einen callback parameter. Damit lassen sich
+ andere Webanwendungen in der menu.ini integrieren.
+ - Im Lagerbewegungsbericht wird nun eine Spalte "Dokument" angezeigt, die auf
+ die Belege verlinkt.
+ - locale stellt jetzt immer die iconv Objekte bereit um Datenbankcharset <->
+ ISO-8859-1 zu konvertieren, auch wenn die Sprache selber nicht existiert.
+ - Upgrade auf JQuery 1.3.1
+ - Das Testframework über selenium wurde entfernt.
+ - Ein neues Testframework in Anlehnung an die Tests von Bugzilla wurde
+ eingeführt.
+ - Das komplette Programm läuft jetzt im Perl strict Modus. Neuer Code muss
+ zwingend ebenfalls strict geschrieben werden.
+
+
+
+ Bugfixes:
+
+ - Eine Funktion zum Auslesen von Lieferanten war nicht gegen mehrfache Aufrufe
+ abgesichert.
+ - Der Workflow Auftrag -> Lieferschein konnte unter Umständen auf das falsche
+ Script verweisen, oder es wurden Felder nicht übernommen.
+ - Die Auftragssuche ergab bei bestimmten Werten der Listenbegrenzung
+ fehlerhafte Anzeigen.
+ - Unter Umständen gingen bei Kreditorenbuchungen die Bemerkungen verloren.
+ - Ein Fehler in der Saldenberechnung der Kontenübersicht wurde behoben.
+ - Das Zahlungsdatum bei gebuchten Zahlungen war unter Umständen nicht korrekt.
+ - Die Dimension von Datenbankfeldern war zu klein für Belege über einer
+ Milliarde.
+ - Kompatibilität zu Postgres 8.4.
+ - Beim Erzeugen einer Einkaufsrechnung aus mehreren Lieferscheinen wurde
+ fälschlicherweise iene Verkaufsrechnung erzeugt.
+ - Im Ausdruck von Angeboten/Aufträgen wurden Lieferanteninformationen unter
+ bestimmten Umständen nicht weitergegeben.
+ - Einige Codingfehler in selten benutzten Fehlermeldungen wurden behoben.
+ - In der Suche von Lieferscheinen war das Verhalten der "offen" und
+ "geschlossen" Checkboxen inkonsistent mit dem restlichen Programm.
+ - Beim Erstellen eines neuen Benutzers wurden OpenDocument Vorlagen nicht
+ kopiert.
+ - Ein IE5 Bugfix von CGI::Ajax hat Probleme bei bestimmten Werten gemacht, und
+ wurde entfernt.
+ - Nach dem speichern einer Rechnung wurde die Folgeanzeige nicht korrekt
+ befüllt.
+ - Dienstleistungen wurden beim speichern fälschlicherweise auf Warenbestand
+ überprüft.
+ - Es gab Probleme in der Auftragssuche nach Projektnummer, wenn eine niedriger
+ Auswahllistenbeschränkung eingestellt war.
+ - Fehler und potentielle Sicherheitslücken in der Historiensuchmaschine
+ beseitigt.
+ - Es wurden einige "division by zero" Fehler im Zusammenhang mit Preisfaktoren
+ behoben.
+ - Das XUL Menü zeigt jetzt wieder korrekt den Titlestring an.
+ - Es wurden in der Lieferübersicht von Lieferanten fehlerhafte Werte
+ angezeigt.
+ - In der Adminitrationsmaske gab es einen Bug der dazu führte, dass Mitglieder
+ einer Rechtegruppe mehrfach auftauchten.
+ - Suche nach Lieferscheinen mit einer bestimmten Projektnummer war fehlerhaft.
+ - Einheiten in Druckvorlagen wurden nicht lokalisiert.
+ - Daten und Zahlen wurden in Druckvorlagen unter Umständen nicht korrekt
+ formatiert.
+ - Bei Einkaufsrechnungen gab es Probleme mit der Rabattberechnung.
+ - Lieferanten in Einkaufsrechnungen wurden nicht richtig formatiert.
+
+
+
+ Liste gefixter Bugs aus dem Bugtracker:
+
+ 922 940 1024 1025 1028 1030 1031 1034 1035 1037 1040 1043 1044 1046 1051 1055
+ 1057 1058 1073 1077 1081 1082 1098 1100 1101 1108 1110 1118 1125 1127 1133
+ 1136 1138 1147 1150 1151 1155 1164 1186 1190 1191 1199 1201
+
+
2009-06-02 - Version 2.6.0
Größere neue Features:
'SAVED FOR DUNNING' => 'Gespeichert',
'SCREENED' => 'Angezeigt',
'Sales Invoice' => 'Rechnung',
+ 'Salesperson' => 'Verkäufer/in',
'Sales Order' => 'Kundenauftrag',
'Sales quotation' => 'Angebot',
'Screen' => 'Bildschirm',
'SCREENED' => 'SCREENED',
'Sales Invoice' => 'Sales Invoice',
'Sales Order' => 'Sales Order',
+ 'Salesperson' => 'Salesperson',
'Sales quotation' => 'Sales quotation',
'Screen' => 'Screen',
'Select a Customer' => 'Select a Customer',
--- /dev/null
+-- @tag: fix_datepaid
+-- @description: Felder datepaid in ar und ap richtig setzen
+-- @depends: release_2_6_0
+
+UPDATE ap
+ SET datepaid = COALESCE((SELECT MAX(at.transdate)
+ FROM acc_trans at
+ LEFT JOIN chart c ON (at.chart_id = c.id)
+ WHERE (at.trans_id = ap.id)
+ AND (c.link LIKE '%paid%')),
+ COALESCE(ap.mtime::date, ap.itime::date))
+ WHERE paid <> 0;
+
+UPDATE ar
+ SET datepaid = COALESCE((SELECT MAX(at.transdate)
+ FROM acc_trans at
+ LEFT JOIN chart c ON (at.chart_id = c.id)
+ WHERE (at.trans_id = ar.id)
+ AND (c.link LIKE '%paid%')),
+ COALESCE(ar.mtime::date, ar.itime::date))
+ WHERE paid <> 0;
<tr>
<th align="right" nowrap>Alte Mahnungen anzeigen</th>
<td><input type="checkbox" value="1" name="showold"></td>
+ <th align="right" nowrap>Verkäufer anzeigen</th>
+ <td><input type="checkbox" value="1" name="l_salesman"></td>
</tr>
</table>
</td>