Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 330c2119

Von Sven Schöling vor fast 3 Jahren hinzugefügt

  • ID 330c21190f7c7cb55d99bfc132a35633ea8d4a84
  • Vorgänger 995ea08d
  • Nachfolger 0ae21038

DeliveryOrder: package, namespace, template und controller referenzen angepasst

Unterschiede anzeigen:

SL/Controller/DeliveryOrder.pm
1
package SL::Controller::Order;
1
package SL::Controller::DeliveryOrder;
2 2

  
3 3
use strict;
4 4
use parent qw(SL::Controller::Base);
......
77 77

  
78 78
  $self->pre_render();
79 79
  $self->render(
80
    'order/form',
80
    'delivery_order/form',
81 81
    title => $self->get_title_for('add'),
82 82
    %{$self->{template_args}}
83 83
  );
......
105 105

  
106 106
  $self->pre_render();
107 107
  $self->render(
108
    'order/form',
108
    'delivery_order/form',
109 109
    title => $self->get_title_for('edit'),
110 110
    %{$self->{template_args}}
111 111
  );
......
128 128

  
129 129
  # fall back to save as new if only one id is given
130 130
  if (scalar @multi_ids == 1) {
131
    $self->order(SL::DB::Order->new(id => $multi_ids[0])->load);
131
    $self->order(SL::DB::DeliveryOrder->new(id => $multi_ids[0])->load);
132 132
    $self->action_save_as_new();
133 133
    return;
134 134
  }
135 135

  
136 136
  # make new order from given orders
137
  my @multi_orders = map { SL::DB::Order->new(id => $_)->load } @multi_ids;
137
  my @multi_orders = map { SL::DB::DeliveryOrder->new(id => $_)->load } @multi_ids;
138 138
  $self->{converted_from_oe_id} = join ' ', map { $_->id } @multi_orders;
139
  $self->order(SL::DB::Order->new_from_multi(\@multi_orders, sort_sources_by => 'transdate'));
139
  $self->order(SL::DB::DeliveryOrder->new_from_multi(\@multi_orders, sort_sources_by => 'transdate'));
140 140

  
141 141
  $self->action_edit();
142 142
}
......
206 206
  }
207 207

  
208 208
  # load order from db to check if values changed
209
  my $saved_order = SL::DB::Order->new(id => $order->id)->load;
209
  my $saved_order = SL::DB::DeliveryOrder->new(id => $order->id)->load;
210 210

  
211 211
  my %new_attrs;
212 212
  # Lets assign a new number if the user hasn't changed the previous one.
......
239 239
  $new_attrs{employee}  = SL::DB::Manager::Employee->current;
240 240

  
241 241
  # Create new record from current one
242
  $self->order(SL::DB::Order->new_from($order, destination_type => $order->type, attributes => \%new_attrs));
242
  $self->order(SL::DB::DeliveryOrder->new_from($order, destination_type => $order->type, attributes => \%new_attrs));
243 243

  
244 244
  # no linked records on save as new
245 245
  delete $::form->{$_} for qw(converted_from_oe_id converted_from_orderitems_ids);
......
677 677
  $self->get_item_cvpartnumber($item);
678 678

  
679 679
  my $item_id = join('_', 'new', Time::HiRes::gettimeofday(), int rand 1000000000000);
680
  my $row_as_html = $self->p->render('order/tabs/_row',
680
  my $row_as_html = $self->p->render('delivery_order/tabs/_row',
681 681
                                     ITEM => $item,
682 682
                                     ID   => $item_id,
683 683
                                     SELF => $self,
......
707 707
      $self->order->add_items( $item );
708 708
      $self->get_item_cvpartnumber($item);
709 709
      my $item_id = join('_', 'new', Time::HiRes::gettimeofday(), int rand 1000000000000);
710
      my $row_as_html = $self->p->render('order/tabs/_row',
710
      my $row_as_html = $self->p->render('delivery_order/tabs/_row',
711 711
                                         ITEM => $item,
712 712
                                         ID   => $item_id,
713 713
                                         SELF => $self,
......
764 764
  foreach my $item (@items) {
765 765
    $self->get_item_cvpartnumber($item);
766 766
    my $item_id = join('_', 'new', Time::HiRes::gettimeofday(), int rand 1000000000000);
767
    my $row_as_html = $self->p->render('order/tabs/_row',
767
    my $row_as_html = $self->p->render('delivery_order/tabs/_row',
768 768
                                       ITEM => $item,
769 769
                                       ID   => $item_id,
770 770
                                       SELF => $self,
......
893 893
  $_->{render_longdescription} = 1 for @{ $self->order->items_sorted };
894 894

  
895 895
  $self->render(
896
    'order/form',
896
    'delivery_order/form',
897 897
    title => $self->get_title_for('edit'),
898 898
    %{$self->{template_args}}
899 899
  );
......
980 980
    $item->parse_custom_variable_values;
981 981
  }
982 982

  
983
  my $row_as_html = $self->p->render('order/tabs/_second_row', ITEM => $item, TYPE => $self->type);
983
  my $row_as_html = $self->p->render('delivery_order/tabs/_second_row', ITEM => $item, TYPE => $self->type);
984 984

  
985 985
  $self->js
986 986
    ->html('#second_row_' . $item_id, $row_as_html)
......
1171 1171
# Needed, if customer/vendor changed.
1172 1172
sub build_business_info_row
1173 1173
{
1174
  $_[0]->p->render('order/tabs/_business_info_row', SELF => $_[0]);
1174
  $_[0]->p->render('delivery_order/tabs/_business_info_row', SELF => $_[0]);
1175 1175
}
1176 1176

  
1177 1177

  
1178
sub render_price_dialog {
1179
  my ($self, $record_item) = @_;
1180

  
1181
  my $price_source = SL::PriceSource->new(record_item => $record_item, record => $self->order);
1182

  
1183
  $self->js
1184
    ->run(
1185
      'kivi.io.price_chooser_dialog',
1186
      t8('Available Prices'),
1187
      $self->render('order/tabs/_price_sources_dialog', { output => 0 }, price_source => $price_source)
1188
    )
1189
    ->reinit_widgets;
1190

  
1191
#   if (@errors) {
1192
#     $self->js->text('#dialog_flash_error_content', join ' ', @errors);
1193
#     $self->js->show('#dialog_flash_error');
1194
#   }
1195

  
1196
  $self->js->render;
1197
}
1198

  
1199 1178
sub load_order {
1200 1179
  my ($self) = @_;
1201 1180

  
1202 1181
  return if !$::form->{id};
1203 1182

  
1204
  $self->order(SL::DB::Order->new(id => $::form->{id})->load);
1183
  $self->order(SL::DB::DeliveryOrder->new(id => $::form->{id})->load);
1205 1184

  
1206 1185
  # Add an empty custom shipto to the order, so that the dialog can render the cvar inputs.
1207 1186
  # You need a custom shipto object to call cvars_by_config to get the cvars.
......
1223 1202
  # be retrieved via items until the order is saved. Adding empty items to new
1224 1203
  # order here solves this problem.
1225 1204
  my $order;
1226
  $order   = SL::DB::Order->new(id => $::form->{id})->load(with => [ 'orderitems', 'orderitems.part' ]) if $::form->{id};
1227
  $order ||= SL::DB::Order->new(orderitems  => [],
1205
  $order   = SL::DB::DeliveryOrder->new(id => $::form->{id})->load(with => [ 'orderitems', 'orderitems.part' ]) if $::form->{id};
1206
  $order ||= SL::DB::DeliveryOrder->new(orderitems  => [],
1228 1207
                                quotation   => (any { $self->type eq $_ } (sales_quotation_type(), request_quotation_type())),
1229 1208
                                currency_id => $::instance_conf->get_currency_id(),);
1230 1209

  
......
1278 1257
  # add_custom_variables adds cvars to an orderitem with no cvars for saving, but
1279 1258
  # they cannot be retrieved via custom_variables until the order/orderitem is
1280 1259
  # saved. Adding empty custom_variables to new orderitem here solves this problem.
1281
  $item ||= SL::DB::OrderItem->new(custom_variables => []);
1260
  $item ||= SL::DB::DeliveryOrderItem->new(custom_variables => []);
1282 1261

  
1283 1262
  $item->assign_attributes(%$attr);
1284 1263

  
......
1298 1277
sub new_item {
1299 1278
  my ($record, $attr) = @_;
1300 1279

  
1301
  my $item = SL::DB::OrderItem->new;
1280
  my $item = SL::DB::DeliveryOrderItem->new;
1302 1281

  
1303 1282
  # Remove attributes where the user left or set the inputs empty.
1304 1283
  # So these attributes will be undefined and we can distinguish them
......
1461 1440
      $self->order->custom_shipto(undef);
1462 1441
    }
1463 1442

  
1464
    SL::DB::OrderItem->new(id => $_)->delete for @{$self->item_ids_to_delete || []};
1443
    SL::DB::DeliveryOrderItem->new(id => $_)->delete for @{$self->item_ids_to_delete || []};
1465 1444
    $self->order->save(cascade => 1);
1466 1445

  
1467 1446
    # link records
1468 1447
    if ($::form->{converted_from_oe_id}) {
1469 1448
      my @converted_from_oe_ids = split ' ', $::form->{converted_from_oe_id};
1470 1449
      foreach my $converted_from_oe_id (@converted_from_oe_ids) {
1471
        my $src = SL::DB::Order->new(id => $converted_from_oe_id)->load;
1450
        my $src = SL::DB::DeliveryOrder->new(id => $converted_from_oe_id)->load;
1472 1451
        $src->update_attributes(closed => 1) if $src->type =~ /_quotation$/;
1473 1452
        $src->link_to_record($self->order);
1474 1453
      }
......
1508 1487

  
1509 1488
  my $destination_type = $::form->{type} eq sales_order_type() ? sales_quotation_type() : request_quotation_type();
1510 1489

  
1511
  $self->order(SL::DB::Order->new_from($self->order, destination_type => $destination_type));
1490
  $self->order(SL::DB::DeliveryOrder->new_from($self->order, destination_type => $destination_type));
1512 1491
  $self->{converted_from_oe_id} = delete $::form->{id};
1513 1492

  
1514 1493
  # set item ids to new fake id, to identify them as new items
......
1531 1510
  $_->{render_second_row} = 1 for @{ $self->order->items_sorted };
1532 1511

  
1533 1512
  $self->render(
1534
    'order/form',
1513
    'delivery_order/form',
1535 1514
    title => $self->get_title_for('edit'),
1536 1515
    %{$self->{template_args}}
1537 1516
  );
......
1559 1538
  my $custom_shipto;
1560 1539
  if (   $::form->{type} eq sales_order_type() && $destination_type eq purchase_order_type()
1561 1540
      && $::form->{use_shipto} && $self->order->shipto) {
1562
    $custom_shipto = $self->order->shipto->clone('SL::DB::Order');
1541
    $custom_shipto = $self->order->shipto->clone('SL::DB::DeliveryOrder');
1563 1542
  }
1564 1543

  
1565
  $self->order(SL::DB::Order->new_from($self->order, destination_type => $destination_type));
1544
  $self->order(SL::DB::DeliveryOrder->new_from($self->order, destination_type => $destination_type));
1566 1545
  $self->{converted_from_oe_id} = delete $::form->{id};
1567 1546

  
1568 1547
  # set item ids to new fake id, to identify them as new items
......
1594 1573
  $_->{render_second_row} = 1 for @{ $self->order->items_sorted };
1595 1574

  
1596 1575
  $self->render(
1597
    'order/form',
1576
    'delivery_order/form',
1598 1577
    title => $self->get_title_for('edit'),
1599 1578
    %{$self->{template_args}}
1600 1579
  );
......
1695 1674
        ],
1696 1675
        action => [
1697 1676
          t8('Save and Quotation'),
1698
          submit   => [ '#order_form', { action => "Order/sales_quotation" } ],
1677
          submit   => [ '#order_form', { action => "DeliveryOrder/sales_quotation" } ],
1699 1678
          only_if  => (any { $self->type eq $_ } (sales_order_type())),
1700 1679
        ],
1701 1680
        action => [
1702 1681
          t8('Save and RFQ'),
1703
          submit   => [ '#order_form', { action => "Order/request_for_quotation" } ],
1682
          submit   => [ '#order_form', { action => "DeliveryOrder/request_for_quotation" } ],
1704 1683
          only_if  => (any { $self->type eq $_ } (purchase_order_type())),
1705 1684
        ],
1706 1685
        action => [
1707 1686
          t8('Save and Sales Order'),
1708
          submit   => [ '#order_form', { action => "Order/sales_order" } ],
1687
          submit   => [ '#order_form', { action => "DeliveryOrder/sales_order" } ],
1709 1688
          only_if  => (any { $self->type eq $_ } (sales_quotation_type(), purchase_order_type())),
1710 1689
        ],
1711 1690
        action => [
......
2113 2092

  
2114 2093
the controller
2115 2094

  
2116
=item * C<template/webpages/order/form.html>
2095
=item * C<template/webpages/delivery_order/form.html>
2117 2096

  
2118 2097
main form
2119 2098

  
2120
=item * C<template/webpages/order/tabs/basic_data.html>
2099
=item * C<template/webpages/delivery_order/tabs/basic_data.html>
2121 2100

  
2122 2101
Main tab for basic_data.
2123 2102

  
......
2126 2105

  
2127 2106
=over 4
2128 2107

  
2129
=item * C<template/webpages/order/tabs/_business_info_row.html>
2108
=item * C<template/webpages/delivery_order/tabs/_business_info_row.html>
2130 2109

  
2131 2110
For displaying information on business type
2132 2111

  
2133
=item * C<template/webpages/order/tabs/_item_input.html>
2112
=item * C<template/webpages/delivery_order/tabs/_item_input.html>
2134 2113

  
2135 2114
The input line for items
2136 2115

  
2137
=item * C<template/webpages/order/tabs/_row.html>
2116
=item * C<template/webpages/delivery_order/tabs/_row.html>
2138 2117

  
2139 2118
One row for already entered items
2140 2119

  
2141
=item * C<template/webpages/order/tabs/_tax_row.html>
2120
=item * C<template/webpages/delivery_order/tabs/_tax_row.html>
2142 2121

  
2143 2122
Displaying tax information
2144 2123

  
2145
=item * C<template/webpages/order/tabs/_price_sources_dialog.html>
2146

  
2147
Dialog for selecting price and discount sources
2148

  
2149 2124
=back
2150 2125

  
2151 2126
=item * C<js/kivi.Order.js>

Auch abrufbar als: Unified diff