use SL::MoreCommon;
use SL::DB::Default;
use SL::TransNumber;
+use SL::Util qw(trim);
use strict;
do_query($form, $dbh, $query, $form->{paid}, $form->{paid} ? conv_date($form->{datepaid}) : undef, conv_i($form->{id}));
}
+ $form->new_lastmtime('ar');
+
# add paid transactions
for my $i (1 .. $form->{paidaccounts}) {
if ($form->{customernumber}) {
$where .= " AND c.customernumber = ?";
- push(@values, $form->{customernumber});
+ push(@values, trim($form->{customernumber}));
}
if ($form->{customer_id}) {
$where .= " AND a.customer_id = ?";
push(@values, $form->{customer_id});
} elsif ($form->{customer}) {
$where .= " AND c.name ILIKE ?";
- push(@values, $form->like($form->{customer}));
+ push(@values, like($form->{customer}));
}
if ($form->{"cp_name"}) {
$where .= " AND (cp.cp_name ILIKE ? OR cp.cp_givenname ILIKE ?)";
- push(@values, ('%' . $form->{"cp_name"} . '%')x2);
+ push(@values, (like($form->{"cp_name"}))x2);
}
if ($form->{business_id}) {
my $business_id = $form->{business_id};
push(@values, $department_id);
}
if ($form->{department}) {
- my $department = "%" . $form->{department} . "%";
+ my $department = like($form->{department});
$where .= " AND d.description ILIKE ?";
push(@values, $department);
}
foreach my $column (qw(invnumber ordnumber cusordnumber notes transaction_description)) {
if ($form->{$column}) {
$where .= " AND a.$column ILIKE ?";
- push(@values, $form->like($form->{$column}));
+ push(@values, like($form->{$column}));
}
}
if ($form->{"project_id"}) {
if ($form->{transdatefrom}) {
$where .= " AND a.transdate >= ?";
- push(@values, $form->{transdatefrom});
+ push(@values, trim($form->{transdatefrom}));
}
if ($form->{transdateto}) {
$where .= " AND a.transdate <= ?";
- push(@values, $form->{transdateto});
+ push(@values, trim($form->{transdateto}));
}
if ($form->{duedatefrom}) {
$where .= " AND a.duedate >= ?";
- push(@values, $form->{duedatefrom});
+ push(@values, trim($form->{duedatefrom}));
}
if ($form->{duedateto}) {
$where .= " AND a.duedate <= ?";
- push(@values, $form->{duedateto});
+ push(@values, trim($form->{duedateto}));
}
if ($form->{open} || $form->{closed}) {
unless ($form->{open} && $form->{closed}) {
$query = qq|UPDATE ar SET paid = amount + paid, storno = 't' WHERE id = ?|;
do_query($form, $dbh, $query, $id);
+ $form->new_lastmtime('ar') if $id == $form->{id};
+
# now copy acc_trans entries
$query = qq|SELECT a.*, c.link FROM acc_trans a LEFT JOIN chart c ON a.chart_id = c.id WHERE a.trans_id = ? ORDER BY a.acc_trans_id|;
my $rowref = selectall_hashref_query($form, $dbh, $query, $id);