{
$form->error("Access Denied");
}
-
&invoice_links;
&prepare_invoice;
+ $form->{format} ="pdf";
+
&display_form;
$lxdebug->leave_sub();
sub edit {
$lxdebug->enter_sub();
-print STDERR "is.pl-edit\n";
+
$form->{title} = $locale->text('Edit Sales Invoice');
if ($myconfig{acs} =~ "AR--Add Sales Invoice" || $myconfig{acs} =~ "AR--AR")
{
$form->error("Access Denied");
}
-
+ if ($form->{print_and_post}) {
+ $form->{action} = "print";
+ $form->{resubmit} = 1;
+ }
&invoice_links;
&prepare_invoice;
&display_form;
sub invoice_links {
$lxdebug->enter_sub();
-print STDERR "is.pl-invoice_links\n";
+
$form->{vc} = 'customer';
# create links
sub prepare_invoice {
$lxdebug->enter_sub();
-print STDERR "is.pl-prepare_invoice\n";
+
$form->{type} = "invoice";
$form->{formname} = "invoice";
- $form->{format} = "html";
$form->{media} = "screen";
if ($form->{id}) {
map { $form->{$_} =~ s/\"/"/g }
qw(invnumber ordnumber quonumber shippingpoint shipvia notes intnotes);
-# # get pricegroups for parts
-# IS->get_pricegroups_for_parts(\%myconfig, \%$form);
+ # # get pricegroups for parts
+ # IS->get_pricegroups_for_parts(\%myconfig, \%$form);
foreach $ref (@{ $form->{invoice_details} }) {
$i++;
$form->{"sellprice_$i"} =
$form->format_amount(\%myconfig, $form->{"sellprice_$i"},
$decimalplaces);
- $form->{"qty_$i"} = $form->format_amount(\%myconfig, $form->{"qty_$i"});
+
+ (my $dec_qty) = ($form->{"qty_$i"} =~ /\.(\d+)/);
+ $dec_qty = length $dec_qty;
+
+ $form->{"qty_$i"} =
+ $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty);
map { $form->{"${_}_$i"} =~ s/\"/"/g }
qw(partnumber description unit partnotes);
$form->{rowcount} = $i;
-# # build up html code for prices_$i
-# print STDERR "set_pricegroup aus is.pl-prepare_invoice\n";
-# set_pricegroup();
}
}
$lxdebug->leave_sub();
sub form_header {
$lxdebug->enter_sub();
-print STDERR "is.pl-form_header\n";
+
# set option selected
foreach $item (qw(AR customer currency department employee contact)) {
$form->{"select$item"} =~ s/ selected//;
$button2 =
qq|<td width="13"><input name=duedate size=11 title="$myconfig{dateformat}" value=$form->{duedate}></td>|;
}
- if ($form->{resubmit}) {
- $onload = "document.invoice.submit()";
+ if ($form->{resubmit} && ($form->{format} eq "html")) {
+ $onload = qq|window.open('about:blank','Beleg'); document.invoice.target = 'Beleg';document.invoice.submit()|;
+ } elsif($form->{resubmit}) {
+ $onload = qq|document.invoice.submit()|;
} else {
$onload = "fokus()";
}
sub form_footer {
$lxdebug->enter_sub();
-print STDERR "is.pl-form_footer\n";
+
$form->{invtotal} = $form->{invsubtotal};
if (($rows = $form->numtextrows($form->{notes}, 26, 8)) < 2) {
<input type=hidden name=selectAR_paid value="$form->{selectAR_paid}">
<input type=hidden name=oldinvtotal value=$form->{oldinvtotal}>
<input type=hidden name=oldtotalpaid value=$totalpaid>
-<input type=hidden name=print_and_post value=$form->{print_and_post}>
-<input type=hidden name=second_run value=$form->{second_run}>
</table>
</td>
</tr>
sub update {
$lxdebug->enter_sub();
-print STDERR "is.pl-update\n";
+
map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
qw(exchangerate creditlimit creditremaining);
-
+ if ($form->{second_run}) {
+ $form->{print_and_post} = 0;
+ }
&check_name(customer);
&check_project;
} else {
$sellprice = $form->format_amount(\%myconfig, $form->{"sellprice_$i"});
-#print STDERR " SELLPRICE-111- $sellprice\n";
+
map { $form->{item_list}[$i]{$_} =~ s/\"/"/g }
qw(partnumber description unit);
map { $form->{"${_}_$i"} = $form->{item_list}[0]{$_} }
}
# get pricegroups for parts
- IS->get_pricegroups_for_parts(\%myconfig, \%$form, "new");
+ IS->get_pricegroups_for_parts(\%myconfig, \%$form);
# build up html code for prices_$i
- set_pricegroup();
+ &set_pricegroup($i);
}
&display_form;
sub post {
$lxdebug->enter_sub();
-print STDERR "is.pl-post\n";
$form->isblank("invdate", $locale->text('Invoice Date missing!'));
$form->isblank("customer", $locale->text('Customer missing!'));
&update;
exit;
}
+ if ($form->{second_run}) {
+ $form->{print_and_post} = 0;
+ }
&validate_items;
$form->{id} = 0 if $form->{postasnew};
- $form->{invnumber} = $form->update_defaults(\%myconfig, "invnumber")
- unless $form->{invnumber};
+ # get new invnumber in sequence if no invnumber is given or if posasnew was requested
+ if (!$form->{invnumber} || $form->{postasnew}) {
+ $form->{invnumber} = $form->update_defaults(\%myconfig, "invnumber")
+ }
if ($print_post) {
if (!(IS->post_invoice(\%myconfig, \%$form))) {
$form->error($locale->text('Cannot post invoice!'));
$print_post = 1;
$form->{print_and_post} = 1;
&post();
- &display_form();
+
+ &edit();
$lxdebug->leave_sub();
}
sub delete {
$lxdebug->enter_sub();
-
+ if ($form->{second_run}) {
+ $form->{print_and_post} = 0;
+ }
$form->header;
print qq|