$reference_date = $reference_date ? conv_dateq($reference_date) . '::DATE' : 'current_date';
my $dbh = $self->get_standard_dbh($myconfig);
+ my $payment_id;
+
+ if($self->{payment_id}) {
+ $payment_id = $self->{payment_id};
+ } elsif($self->{vendor_id}) {
+ my $query = 'SELECT payment_id FROM vendor WHERE id = ?';
+ ($payment_id) = selectrow_query($self, $dbh, $query, $self->{vendor_id});
+ }
+
my $query = qq|SELECT ${reference_date} + terms_netto FROM payment_terms WHERE id = ?|;
- my ($duedate) = selectrow_query($self, $dbh, $query, $self->{payment_id});
+ my ($duedate) = selectrow_query($self, $dbh, $query, $payment_id);
$main::lxdebug->leave_sub();
# with JavaScript Calendar
$button1 = qq|
- <td><input name=transdate id=transdate size=11 title="$myconfig{dateformat}" value="$form->{transdate}" onBlur=\"check_right_date_format(this)\" $readonly></td>
+ <td><input name=transdate onchange="set_duedate()" id=transdate size=11 title="$myconfig{dateformat}" value="$form->{transdate}" onBlur=\"check_right_date_format(this)\" $readonly></td>
<td><input type=button name=transdate id="trigger1" value=|
. $locale->text('button') . qq|></td>
|;
# without JavaScript Calendar
$button1 =
- qq|<td><input name=transdate id=transdate size=11 title="$myconfig{dateformat}" value="$form->{transdate}" onBlur=\"check_right_date_format(this)\" $readonly></td>|;
+ qq|<td><input name=transdate onchange="set_duedate()" id=transdate size=11 title="$myconfig{dateformat}" value="$form->{transdate}" onBlur=\"check_right_date_format(this)\" $readonly></td>|;
$button2 =
qq|<td><input name=duedate id=duedate size=11 title="$myconfig{dateformat}" value="$form->{duedate}" onBlur=\"check_right_date_format(this)\" $readonly></td>|;
}
$follow_ups_block
+<script type="text/javascript">
+<!--
+function set_duedate() {
+ \$.ajax({
+ url: 'is.pl?action=set_duedate',
+ data: {
+ invdate: \$('#transdate').val(),
+ vendor_id: \$('[name=vendor_id]').val(),
+ },
+ dataType: 'text',
+ success: function(data) {
+ \$('#duedate').val(data);
+ }
+ });
+ }
+//-->
+</script>
+
<input name=callback type=hidden value="$form->{callback}">
<input name="gldate" type="hidden" value="| . Q($form->{gldate}) . qq|">
|