# show history button
$form->{javascript} = qq|<script type=text/javascript src=js/show_history.js></script>|;
#/show hhistory button
-
+
$form->{title} = $locale->text('Edit Vendor Invoice');
&invoice_links;
IR->get_vendor(\%myconfig, \%$form);
IR->retrieve_invoice(\%myconfig, \%$form);
$form->{cp_id} = $cp_id;
-
+
if ($payment_id) {
$form->{payment_id} = $payment_id;
}
$auth->assert('vendor_invoice_edit');
+ push @{ $form->{AJAX} }, CGI::Ajax->new('set_duedate_vendor' => "$form->{script}?action=set_duedate_vendor");
+
# set option selected
foreach $item (qw(AP vendor currency department)) {
$form->{"select$item"} =~ s/ selected//;
}
my $globalprojectnumber = NTI($cgi->popup_menu('-name' => 'globalproject_id', '-values' => \@values, '-labels' => \%labels,
'-default' => $form->{"globalproject_id"}));
-
+
%labels = ();
@values = ();
my $i = 0;
push(@values, $item);
$labels{$item} = $item;
}
-
+
$form->{currency} = $form->{defaultcurrency} unless $form->{currency};
my $currencies;
if (scalar @values) {
: (NTI($cgi->popup_menu('-name' => 'vendor', '-default' => $form->{oldvendor},
'-onChange' => 'document.getElementById(\'update_button\').click();',
'-values' => \@values, '-labels' => \%labels, '-style' => 'width: 250px')))) . qq|
- <input type="button" value="?" onclick="show_vc_details('vendor')">
+ <input type="button" value="| . $locale->text('Details (one letter abbreviation)') . qq|" onclick="show_vc_details('vendor')">
</td>|;
%labels = ();
$jsscript = "";
$button1 = qq|
- <td><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=| . $locale->text('button') . qq|></td>\n|;
+ <td nowrap>
+ <input name=invdate id=invdate size=11 title="$myconfig{dateformat}" value="$form->{invdate}" onBlur=\"check_right_date_format(this)\"
+ onChange="if (this.value) set_duedate_vendor(['invdate__' + this.value, 'old_duedate__' + document.getElementsByName('duedate')[0].value, 'vendor_id__' + document.getElementsByName('vendor_id')[0].value],['duedate'])">
+ <input type=button name=invdate id="trigger1" value="?">
+ </td>\n|;
+
+#, 'old_duedate__'' + document.getElementsByName('duedate')[0].value, 'vendor_id__' + document.getElementsByName('vendor_id')[0].value],['duedate'])">
$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=| . $locale->text('button') . qq|></td>\n|;
+ <td width="13" nowrap>
+ <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=| . $locale->text('button') . qq|>
+ </td>\n|;
#write Trigger
$jsscript =
- Form->write_trigger(\%myconfig, "2",
+ Form->write_trigger(\%myconfig, "2",
"invdate", "BL", "trigger1",
"duedate", "BL", "trigger2");
print qq|
<body onLoad="$onload">
<script type="text/javascript" src="js/common.js"></script>
-<form method=post action=$form->{script}>
+<form method="post" action="ir.pl" name="Form">
|;
$form->hide_form(qw(id title vc type level creditlimit creditremaining closedto locked shippted storno storno_id
max_dunning_level dunning_amount vendor_id oldvendor selectvendor taxaccounts
- fxgain_accno fxloss_accno taxpart taxservice cursor_fokus),
+ fxgain_accno fxloss_accno taxpart taxservice cursor_fokus
+ convert_from_oe_ids convert_from_do_ids),
map { $_.'_rate', $_.'_description' } split / /, $form->{taxaccounts} );
print qq|<p>$form->{saved_message}</p>| if $form->{saved_message};
<td align=right>
<table>
$employees
- <tr>
+ <tr>
<th align=right nowrap>| . $locale->text('Invoice Number') . qq|</th>
<td><input name=invnumber size=11 value="$form->{invnumber}"></td>
</tr>
qq|<td align=center><input name="datepaid_$i" id="datepaid_$i" size=11 title="$myconfig{dateformat}" value="$form->{"datepaid_$i"}" onBlur=\"check_right_date_format(this)\">
<input type="button" name="datepaid_$i" id="trigger_datepaid_$i" value="?"></td>|;
$column_data{"source_$i"} =
- qq|<td align=center><input name="source_$i" size=11 value=$form->{"source_$i"}></td>|;
+ qq|<td align=center><input name="source_$i" size=11 value="$form->{"source_$i"}"></td>|;
$column_data{"memo_$i"} =
- qq|<td align=center><input name="memo_$i" size=11 value=$form->{"memo_$i"}></td>|;
+ qq|<td align=center><input name="memo_$i" size=11 value="$form->{"memo_$i"}"></td>|;
map { print qq|$column_data{"${_}_$i"}\n| } @column_index;
</tr>
</table>
<br>
-| . $cgi->hidden('-name' => 'close_do_ids', '-default' => [$form->{close_do_ids}]);
+|;
$invdate = $form->datetonum($form->{invdate}, \%myconfig);
$closedto = $form->datetonum($form->{closedto}, \%myconfig);
. qq|">|;
}
# /button for saving history
- # mark_as_paid button
- if($form->{id} ne "") {
- print qq| <input type="submit" class="submit" name="action" value="|
+ # mark_as_paid button
+ if($form->{id} ne "") {
+ print qq| <input type="submit" class="submit" name="action" value="|
. $locale->text('mark as paid') . qq|">|;
}
# /mark_as_paid button
$auth->assert('vendor_invoice_edit');
- &mark_as_paid_common(\%myconfig,"ap");
+ &mark_as_paid_common(\%myconfig,"ap");
$lxdebug->leave_sub();
}
# Payments must not be recorded for the new storno invoice.
$form->{paidaccounts} = 0;
map { my $key = $_; delete $form->{$key} if grep { $key =~ /^$_/ } qw(datepaid_ source_ memo_ paid_ exchangerate_ AR_paid_) } keys %{ $form };
-
+
# saving the history
if(!exists $form->{addition} && $form->{id} ne "") {
- $form->{snumbers} = qq|invnumber_| . $form->{invnumber};
+ $form->{snumbers} = qq|invnumber_| . $form->{invnumber};
$form->{addition} = "CANCELED";
$form->save_history($form->dbconnect(\%myconfig));
}
# /saving the history
-
+
$form->{storno_id} = $form->{id};
$form->{storno} = 1;
$form->{id} = "";
($form->{AP}) = split /--/, $form->{AP};
($form->{AP_paid}) = split /--/, $form->{AP_paid};
- $form->{storno} = 0;
+ $form->{storno} ||= 0;
$form->{id} = 0 if $form->{postasnew};
if (IR->post_invoice(\%myconfig, \%$form)){
# saving the history
if(!exists $form->{addition} && $form->{id} ne "") {
- $form->{snumbers} = qq|invnumber_| . $form->{invnumber};
+ $form->{snumbers} = qq|invnumber_| . $form->{invnumber};
$form->{addition} = "POSTED";
#$form->{what_done} = $locale->text("Rechnungsnummer") . qq| | . $form->{invnumber};
$form->save_history($form->dbconnect(\%myconfig));
if (IR->delete_invoice(\%myconfig, \%$form)) {
# saving the history
if(!exists $form->{addition}) {
- $form->{snumbers} = qq|invnumber_| . $form->{invnumber};
+ $form->{snumbers} = qq|invnumber_| . $form->{invnumber};
$form->{addition} = "DELETED";
$form->save_history($form->dbconnect(\%myconfig));
}
- # /saving the history
+ # /saving the history
$form->redirect($locale->text('Invoice deleted!'));
}
$form->error($locale->text('Cannot delete invoice!'));
$lxdebug->leave_sub();
}
+
+sub set_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});
+
+ $lxdebug->leave_sub();
+}