Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 00c3a0ed

Von Bernd Bleßmann vor mehr als 6 Jahren hinzugefügt

  • ID 00c3a0ed09bf1d9d8e356df8859670a11d782347
  • Vorgänger b4e12203
  • Nachfolger 06806380

Auftrags-Controller: Save as new

Unterschiede anzeigen:

SL/Controller/Order.pm
10 10
use SL::PriceSource;
11 11
use SL::Webdav;
12 12
use SL::File;
13

  
13
use SL::Util qw(trim);
14 14
use SL::DB::Order;
15 15
use SL::DB::Default;
16 16
use SL::DB::Unit;
......
42 42
__PACKAGE__->run_before('_check_auth');
43 43

  
44 44
__PACKAGE__->run_before('_recalc',
45
                        only => [ qw(save save_and_delivery_order save_and_invoice print create_pdf send_email) ]);
45
                        only => [ qw(save save_as_new save_and_delivery_order save_and_invoice print create_pdf send_email) ]);
46 46

  
47 47
__PACKAGE__->run_before('_get_unalterable_data',
48
                        only => [ qw(save save_and_delivery_order save_and_invoice print create_pdf send_email) ]);
48
                        only => [ qw(save save_as_new save_and_delivery_order save_and_invoice print create_pdf send_email) ]);
49 49

  
50 50
#
51 51
# actions
......
133 133
  $self->redirect_to(@redirect_params);
134 134
}
135 135

  
136
# save the order as new document an open it for edit
137
sub action_save_as_new {
138
  my ($self) = @_;
139

  
140
  if (!$self->order->id) {
141
    $self->js->flash('error', t8('This object has not been saved yet.'));
142
    return $self->js->render();
143
  }
144

  
145
  delete $::form->{$_} for qw(closed delivered converted_from_oe_id converted_from_orderitems_ids);
146

  
147
  my $src_order = SL::DB::Order->new(id => $self->order->id)->load;
148

  
149
  # Lets assign a new number if the user hasn't changed the previous one.
150
  # If it has been changed manually then use it as-is.
151
  if (trim($self->order->number) eq $src_order->number) {
152
    $self->order->number('');
153
  }
154

  
155
  # Clear reqdate and transdate unless changed
156
  if ($self->order->transdate == $src_order->transdate) {
157
    $self->order->transdate(DateTime->today_local)
158
  }
159
  if ($self->order->reqdate == $src_order->reqdate) {
160
    my $extra_days = $self->type eq _sales_quotation_type() ? $::instance_conf->get_reqdate_interval : 1;
161
    $self->order->reqdate(DateTime->today_local->next_workday(extra_days => $extra_days));
162
  }
163

  
164
  # Update employee
165
  $self->order->employee(SL::DB::Manager::Employee->current);
166

  
167
  # save
168
  $self->action_save();
169
}
170

  
136 171
# print the order
137 172
#
138 173
# This is called if "print" is pressed in the print dialog.
......
1363 1398
          call      => [ 'kivi.Order.save', $::instance_conf->get_order_warn_duplicate_parts ],
1364 1399
          checks    => [ 'kivi.Order.check_save_active_periodic_invoices' ],
1365 1400
        ],
1401
        action => [
1402
          t8('Save as new'),
1403
          call      => [ 'kivi.Order.save_as_new', $::instance_conf->get_order_warn_duplicate_parts ],
1404
          checks    => [ 'kivi.Order.check_save_active_periodic_invoices' ],
1405
          disabled  => !$self->order->id ? t8('This object has not been saved yet.') : undef,
1406
        ],
1366 1407
        action => [
1367 1408
          t8('Save and Delivery Order'),
1368 1409
          call      => [ 'kivi.Order.save_and_delivery_order', $::instance_conf->get_order_warn_duplicate_parts ],
js/kivi.Order.js
45 45
    $.post("controller.pl", data, kivi.eval_json_result);
46 46
  };
47 47

  
48
  ns.save_as_new = function(warn_on_duplicates) {
49
    if (!ns.check_cv()) return;
50
    if (warn_on_duplicates && !ns.check_save_duplicate_parts()) return;
51

  
52
    var data = $('#order_form').serializeArray();
53
    data.push({ name: 'action', value: 'Order/save_as_new' });
54

  
55
    $.post("controller.pl", data, kivi.eval_json_result);
56
  };
57

  
48 58
  ns.save_and_delivery_order = function(warn_on_duplicates) {
49 59
    if (!ns.check_cv()) return;
50 60
    if (warn_on_duplicates && !ns.check_save_duplicate_parts()) return;

Auch abrufbar als: Unified diff