);
}
+sub action_delete {
+ my ($self) = @_;
+
+ my $errors = $self->_delete();
+
+ if (scalar @{ $errors }) {
+ $self->js->flash('error', $_) foreach @{ $errors };
+ return $self->js->render();
+ }
+
+ flash_later('info', $::locale->text('The order has been deleted'));
+ my @redirect_params = (
+ action => 'edit',
+ type => $self->type,
+ );
+
+ $self->redirect_to(@redirect_params);
+}
+
sub action_save {
my ($self) = @_;
}
+sub _delete {
+ my ($self) = @_;
+
+ my $errors = [];
+ my $db = $self->order->db;
+
+ $db->do_transaction(
+ sub {
+ my @spoolfiles = grep { $_ } map { $_->spoolfile } @{ SL::DB::Manager::Status->get_all(where => [ trans_id => $self->order->id ]) };
+ $self->order->delete;
+ my $spool = $::lx_office_conf{paths}->{spool};
+ unlink map { "$spool/$_" } @spoolfiles if $spool;
+
+ 1;
+ }) || push(@{$errors}, $db->error);
+
+ return $errors;
+}
+
+
sub _save {
my ($self) = @_;
'The number of days for full payment' => 'Die Anzahl Tage, bis die Rechnung in voller Höhe bezahlt werden muss',
'The numbering will start at 1 with each requirement spec.' => 'Die Nummerierung beginnt bei jedem Pflichtenheft bei 1.',
'The option field is empty.' => 'Das Optionsfeld ist leer.',
+ 'The order has been deleted' => 'Der Auftrag wurde gelöscht.',
'The order has been saved' => 'Der Auftrag wurde gespeichert.',
'The package name is invalid.' => 'Der Paketname ist ungültig.',
'The parts for this delivery order have already been transferred in.' => 'Die Artikel dieses Lieferscheins wurden bereits eingelagert.',
[% L.hidden_tag('action', 'Order/dispatch') %]
[% L.button_tag('save()', LxERP.t8('Save')) %]
+[%- IF SELF.order.id && ( (SELF.cv == 'customer' && INSTANCE_CONF.get_sales_order_show_delete) || (SELF.cv == 'vendor' && INSTANCE_CONF.get_purchase_order_show_delete) ) %]
+ [% L.button_tag('delete_order()', LxERP.t8('Delete'), confirm=LxERP.t8("Are you sure?")) %]
+[%- END %]
</form>
<script type='text/javascript'>
+function delete_order() {
+ var data = $('#order_form').serializeArray();
+ data.push({ name: 'action', value: 'Order/delete' });
+
+ $.post("controller.pl", data, kivi.eval_json_result);
+}
+
function save() {
if (!check_cv()) return;
var data = $('#order_form').serialize();