# undo formatting
map {
- $form->{"${_}_$i"} = $form->parse_amount(\%myconfig, $form->{"${_}_$i"})
+ $form->{"${_}_$i"} =
+ $form->parse_amount(\%myconfig, $form->{"${_}_$i"})
} qw(qty ship discount sellprice);
($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/);
&{"$form->{display_form}"};
exit;
}
+ if ( $form->{print_and_post}
+ && $form->{second_run}
+ && ($form->{action} eq "display_form")) {
+ for (keys %$form) { $old_form->{$_} = $form->{$_} }
+ $old_form->{rowcount}++;
+ #$form->{rowcount}--;
+ #$form->{rowcount}--;
+
+ $form->{print_and_post} = 0;
+
+ &print_form($old_form);
+ exit;
+ }
+
+ $form->{action} = "";
+ $form->{resubmit} = 0;
+
+ if ($form->{print_and_post} && !$form->{second_run}) {
+ $form->{second_run} = 1;
+ $form->{action} = "display_form";
+ $form->{rowcount}--;
+
+ $form->{resubmit} = 1;
+
+ }
&form_header;
$numrows = ++$form->{rowcount};
&form_footer;
+ # if ($form->{print_and_post}) {
+ # &display_form;
+ # }
+
$lxdebug->leave_sub();
}
my @a = ();
my $count = 0;
- my @flds = (
+ my @flds = (
qw(id partnumber description qty ship sellprice unit discount inventory_accno income_accno expense_accno listprice taxaccounts bin assembly weight projectnumber project_id oldprojectnumber runningnumber serialnumber partsgroup)
);
# $locale->text('Quotation Date missing!')
# assign number
- if (!$form->{"${inv}number"}) {
+ if (!$form->{"${inv}number"} && !$form->{preview}) {
$form->{"${inv}number"} = $form->update_defaults(\%myconfig, $numberfld);
if ($form->{media} ne 'email') {
$form->{rowcount}--;
? $locale->text('sent to printer')
: $locale->text('emailed to') . " $form->{email}";
$form->redirect(qq|$form->{label} $form->{"${inv}number"} $msg|);
+ } else {
+ &{"$display_form"};
}
$lxdebug->leave_sub();
map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
qw(exchangerate creditlimit creditremaining);
$form_id = $form->{id};
+
# get details for name
&{"$form->{vc}_details"};
$form->{id} = $form_id;
<table>
<tr class=listheading>
<th class=listheading colspan=2 width=50%>|
- . $locale->text('Billing Address')
- . qq|</th>
+ . $locale->text('Billing Address') . qq|</th>
<th class=listheading width=50%>|
- . $locale->text('Shipping Address')
- . qq|</th>
+ . $locale->text('Shipping Address') . qq|</th>
</tr>
<tr height="5"></tr>
<tr>
$button1 = qq|
<td><input name=invdate id=invdate size=11 title="$myconfig{dateformat}" value=$form->{invdate}></td>
<td><input type=button name=invdate id="trigger1" value=|
- . $locale->text('button')
- . qq|></td>
+ . $locale->text('button') . qq|></td>
|;
$button2 = qq|
<td width="13"><input name=duedate id=duedate size=11 title="$myconfig{dateformat}" value=$form->{duedate}></td>
<td width="4"><input type=button name=duedate id="trigger2" value=|
- . $locale->text('button')
- . qq|></td></td>
+ . $locale->text('button') . qq|></td></td>
|;
#write Trigger
$button2 =
qq|<td width="13"><input name=duedate size=11 title="$myconfig{dateformat}" value=$form->{duedate}></td>|;
}
-
+ if ($form->{resubmit}) {
+ $onload = "document.invoice.submit()";
+ } else {
+ $onload = "fokus()";
+ }
$form->header;
print qq|
-<body onLoad="fokus()">
+<body onLoad="$onload">
<form method=post name="invoice" action=$form->{script}>
<input type=hidden name=id value=$form->{id}>
+<input type=hidden name=action value=$form->{action}>
<input type=hidden name=type value=$form->{type}>
<input type=hidden name=media value=$form->{media}>
<input type=hidden name=customer_id value=$form->{customer_id}>
<input type=hidden name=oldcustomer value="$form->{oldcustomer}">
<th align=richt nowrap>|
- . $locale->text('Contact Person')
- . qq|</th>
+ . $locale->text('Contact Person') . qq|</th>
<td colspan=3>$contact</td>
</tr>
<tr>
if ($form->{taxaccounts}) {
$taxincluded = qq|
<input name=taxincluded class=checkbox type=checkbox value=1 $form->{taxincluded}> <b>|
- . $locale->text('Tax Included')
- . qq|</b><br><br>|;
+ . $locale->text('Tax Included') . qq|</b><br><br>|;
}
if (!$form->{taxincluded}) {
<table width=100%>
<tr class=listheading>
<th colspan=6 class=listheading>|
- . $locale->text('Incoming Payments')
- . qq|</th>
+ . $locale->text('Incoming Payments') . qq|</th>
</tr>
|;
<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>
- </table>
+<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>
<tr>
<input class=submit type=submit name=action value="|
. $locale->text('Ship to') . qq|">
<input class=submit type=submit name=action value="|
- . $locale->text('Print') . qq|">
+ . $locale->text('Preview') . qq|">
<input class=submit type=submit name=action value="|
. $locale->text('E-mail') . qq|">
+ <input class=submit type=submit name=action value="|
+ . $locale->text('Print and Post') . qq|">
<input class=submit type=submit name=action value="|
. $locale->text('Post') . qq|">|;
}
$form->{invnumber} = $form->update_defaults(\%myconfig, "invnumber")
unless $form->{invnumber};
-
- $form->redirect(
+ if ($print_post) {
+ if (!(IS->post_invoice(\%myconfig, \%$form))) {
+ $form->error($locale->text('Cannot post invoice!'));
+ }
+ } else {
+ $form->redirect(
$form->{label} . " $form->{invnumber} " . $locale->text('posted!'))
- if (IS->post_invoice(\%myconfig, \%$form));
- $form->error($locale->text('Cannot post invoice!'));
+ if (IS->post_invoice(\%myconfig, \%$form));
+ $form->error($locale->text('Cannot post invoice!'));
+ }
$lxdebug->leave_sub();
}
+sub print_and_post {
+ $lxdebug->enter_sub();
+
+ $old_form = new Form;
+ $print_post = 1;
+ $form->{print_and_post} = 1;
+ &post();
+ &display_form();
+ $lxdebug->leave_sub();
+
+}
+
+sub preview {
+ $lxdebug->enter_sub();
+
+ $form->{preview} = 1;
+ $old_form = new Form;
+ for (keys %$form) { $old_form->{$_} = $form->{$_} }
+ $old_form->{rowcount}++;
+
+ &print_form($old_form);
+ $lxdebug->leave_sub();
+
+}
+
sub delete {
$lxdebug->enter_sub();