sub get_duedate {
$main::lxdebug->enter_sub();
- my ($self, $myconfig) = @_;
+ my ($self, $myconfig, $reference_date) = @_;
- my $dbh = $self->get_standard_dbh($myconfig);
- my $query = qq|SELECT current_date + terms_netto FROM payment_terms WHERE id = ?|;
- ($self->{duedate}) = selectrow_query($self, $dbh, $query, $self->{payment_id});
+ my $reference_date = $reference_date ? conv_dateq($reference_date) . '::DATE' : 'current_date';
+
+ my $dbh = $self->get_standard_dbh($myconfig);
+ my $query = qq|SELECT ${reference_date} + terms_netto FROM payment_terms WHERE id = ?|;
+ my ($duedate) = selectrow_query($self, $dbh, $query, $self->{payment_id});
$main::lxdebug->leave_sub();
+
+ return $duedate;
}
sub _get_contacts {
_check_io_auth();
- $form->get_duedate(\%myconfig);
+ my $invdate = $form->{invdate} eq 'undefined' ? undef : $form->{invdate};
+ my $duedate = $form->get_duedate(\%myconfig, $invdate);
- print $form->ajax_response_header() . $form->{duedate};
+ print $form->ajax_response_header() . $duedate;
$lxdebug->leave_sub();
}
if ($form->{type} eq "credit_note") {
$button1 = qq|
<td nowrap><input name="invdate" id="invdate" size="11" title="$myconfig{dateformat}" value="$form->{invdate}" onBlur=\"check_right_date_format(this)\">
- <input type="button" name="invdate" id="trigger1" value="|
+ <input type="button" name="invdate_button" id="trigger1" value="|
. $locale->text('button') . qq|"></td>|;
#write Trigger
} else {
$button1 = qq|
<td nowrap><input name="invdate" id="invdate" size="11" title="$myconfig{dateformat}" value="$form->{invdate}" onBlur=\"check_right_date_format(this)\">
- <input type="button" name="invdate" id="trigger1" value="|
+ <input type="button" name="invdate_button" id="trigger1" value="|
. $locale->text('button') . qq|"></td>
|;
$button2 = qq|
<td width="13"><input name="duedate" id="duedate" size="11" title="$myconfig{dateformat}" value="$form->{duedate}" onBlur=\"check_right_date_format(this)\">
- <input type="button" name="duedate" id="trigger2" value="|
+ <input type="button" name="duedate_button" id="trigger2" value="|
. $locale->text('button') . qq|"></td>
|;
$button3 = qq|
<td width="13"><input name="deliverydate" id="deliverydate" size="11" title="$myconfig{dateformat}" value="$form->{deliverydate}" onBlur=\"check_right_date_format(this)\">
- <input type="button" name="deliverydate" id="trigger3" value="|
+ <input type="button" name="deliverydate_button" id="trigger3" value="|
. $locale->text('button') . qq|"></td>
|;
<tr valign="top">
<td>$notes</td>
<td>$intnotes</td>
- <td><select name="payment_id" onChange="if (this.value) set_duedate(['payment_id__' + this.value],['duedate'])">$payment
+ <td><select name="payment_id" onChange="if (this.value) set_duedate(['payment_id__' + this.value, 'invdate__' + invdate.value],['duedate'])">$payment
</select></td>
</tr>
$follow_ups_block