$form->{defaultcurrency} = $form->get_default_currency(\%myconfig);
- my $set_duedate_url = "$form->{script}?action=set_duedate";
-
- push @ { $form->{AJAX} }, new CGI::Ajax( 'set_duedate' => $set_duedate_url );
-
my @old_project_ids = ($form->{"globalproject_id"});
map { push @old_project_ids, $form->{"project_id_$_"} if $form->{"project_id_$_"}; } 1..$form->{"rowcount"};
$main::lxdebug->leave_sub();
}
-sub set_duedate_vendor {
- $main::lxdebug->enter_sub();
-
- my $form = $main::form;
+sub get_duedate_vendor {
+ $::lxdebug->enter_sub;
- print $form->ajax_response_header(), IR->get_duedate('vendor_id' => $form->{vendor_id},
- 'invdate' => $form->{invdate},
- 'default' => $form->{old_duedate});
+ my $result = IR->get_duedate(
+ vendor_id => $::form->{vendor_id},
+ invdate => $::form->{invdate},
+ default => $::form->{old_duedate},
+ );
- $main::lxdebug->leave_sub();
+ print $::form->ajax_response_header, $result;
+ $::lxdebug->leave_sub;
}
</tr>
<tr>
<th align="right">[% 'Credit Note Date' | $T8 %]</th>
- <td>[% L.date_tag('invdate', invdate, onBlur='check_right_date_format(this)', cal_align='BL') %]</td>
+ <td>[% L.date_tag('invdate', invdate, onBlur='check_right_date_format(this)', cal_align='BL', onChange='set_duedate(this)') %]</td>
</tr>
[%- ELSE %]
<tr>
</tr>
<tr>
<th align="right">[% 'Invoice Date' | $T8 %]</th>
- <td>[% L.date_tag('invdate', invdate, onBlur='check_right_date_format(this)', cal_align='BL') %]</td>
+ <td>[% L.date_tag('invdate', invdate, onBlur='check_right_date_format(this)', cal_align='BL', onChange='set_duedate(this)') %]</td>
</tr>
<tr>
<th align="right">[% 'Due Date' | $T8 %]</th>
setupDateFormat('[% dateformat %]', '[% 'Falsches Datumsformat!' | $T8 %]');
setupPoints('[% numberformat %]', '[% 'wrongformat' | $T8 %]');
});
+ function set_duedate() {
+ $.ajax({
+ url: 'ir.pl?action=get_duedate_vendor',
+ data: {
+ invdate: $('#invdate').val(),
+ vendor_id: $('input[name="vendor_id"]').val(),
+ old_duedate: $('#duedate').val(),
+ },
+ dataType: 'text',
+ success: function (data) { $('#duedate').val(data); }
+ })
+ }
//-->
</script>