quotation();
}
-sub e_mail {
+sub edit_e_mail {
$lxdebug->enter_sub();
if ($form->{second_run}) {
$form->{print_and_post} = 0;
}
relink_accounts();
- if ($print_post) {
- if (!(IS->post_invoice(\%myconfig, \%$form))) {
- $form->error($locale->text('Cannot post invoice!'));
- }
- remove_draft() if $form->{remove_draft};
- # saving the history
- if(!exists $form->{addition}) {
- $form->{addition} = "PRINTED AND POSTED";
- $form->save_history($form->dbconnect(\%myconfig));
- }
- # /saving the history
-
- } else {
- if (IS->post_invoice(\%myconfig, \%$form)){
- remove_draft() if $form->{remove_draft};
- # saving the history
- if(!exists $form->{addition}) {
- if($form->{storno}) {
- $form->{addition} = "STORNO";
- }
- else {
- $form->{addition} = "POSTED";
- }
- $form->save_history($form->dbconnect(\%myconfig));
- }
- # /saving the history
-
- $form->redirect(
- $form->{label} . " $form->{invnumber} " . $locale->text('posted!'));
- }
- $form->error($locale->text('Cannot post invoice!'));
+ $form->error($locale->text('Cannot post invoice!'))
+ unless IS->post_invoice(\%myconfig, \%$form);
+ remove_draft() if $form->{remove_draft};
+
+ if(!exists $form->{addition}) {
+ $form->{addition} = $print_post ? "PRINTED AND POSTED" :
+ $form->{storno} ? "STORNO" :
+ "POSTED";
+ $form->save_history($form->dbconnect(\%myconfig));
}
+
+ $form->redirect( $form->{label} . " $form->{invnumber} " . $locale->text('posted!'))
+ unless $print_post;
$lxdebug->leave_sub();
}
$lxdebug->leave_sub();
}
+
+sub e_mail {
+ $lxdebug->enter_sub();
+
+ $form->{postasnew} = 1;
+ $print_post = 1;
+
+ map { delete $form->{$_} } qw(printed emailed queued);
+
+ &post;
+
+ &edit_e_mail;
+
+ $lxdebug->leave_sub();
+}
$lxdebug->leave_sub();
}
+sub e_mail {
+ $lxdebug->enter_sub();
+
+ $form->{saveasnew} = 1;
+ $form->{closed} = 0;
+ $form->{print_and_save} = 1;
+ map { delete $form->{$_} } qw(printed emailed queued);
+
+ # Let Lx-Office assign a new order number if the user hasn't changed the
+ # previous one. If it has been changed manually then use it as-is.
+ my $idx = $form->{type} =~ /_quotation$/ ? "quonumber" : "ordnumber";
+ if ($form->{saved_xyznumber} &&
+ ($form->{saved_xyznumber} eq $form->{$idx})) {
+ delete($form->{$idx});
+ }
+
+ &save;
+
+ &edit_e_mail;
+
+ $lxdebug->leave_sub();
+}
+
'delivery_customer_selection' => 'delivery_customer_selection',
'display_form' => 'display_form',
'display_row' => 'display_row',
- 'e_mail' => 'e_mail',
'edit_config' => 'edit_config',
+ 'edit_e_mail' => 'edit_e_mail',
'employee_selection_internal' => 'employee_selection_internal',
'format_dates' => 'format_dates',
'gl_transaction' => 'gl_transaction',
'display' => 'display',
'display_form' => 'display_form',
'display_row' => 'display_row',
- 'e_mail' => 'e_mail',
'edit' => 'edit',
+ 'edit_e_mail' => 'edit_e_mail',
'employee_selection_internal' => 'employee_selection_internal',
'form_footer' => 'form_footer',
'form_header' => 'form_header',
'delivery_customer_selection' => 'delivery_customer_selection',
'display_form' => 'display_form',
'display_row' => 'display_row',
- 'e_mail' => 'e_mail',
+ 'edit_e_mail' => 'edit_e_mail',
'employee_selection_internal' => 'employee_selection_internal',
'format_dates' => 'format_dates',
'invoicetotal' => 'invoicetotal',
'display_row' => 'display_row',
'dont_load_draft' => 'dont_load_draft',
'draft_action_dispatcher' => 'draft_action_dispatcher',
- 'e_mail' => 'e_mail',
'edit' => 'edit',
+ 'edit_e_mail' => 'edit_e_mail',
'employee_selection_internal' => 'employee_selection_internal',
'form_footer' => 'form_footer',
'form_header' => 'form_header',
'display_row' => 'display_row',
'dont_load_draft' => 'dont_load_draft',
'draft_action_dispatcher' => 'draft_action_dispatcher',
- 'e_mail' => 'e_mail',
'edit' => 'edit',
+ 'edit_e_mail' => 'edit_e_mail',
'employee_selection_internal' => 'employee_selection_internal',
'form_footer' => 'form_footer',
'form_header' => 'form_header',
'display_row' => 'display_row',
'e_mail' => 'e_mail',
'edit' => 'edit',
+ 'edit_e_mail' => 'edit_e_mail',
'employee_selection_internal' => 'employee_selection_internal',
'form_footer' => 'form_footer',
'form_header' => 'form_header',