Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 9d77db68

Von Kivitendo Admin vor mehr als 8 Jahren hinzugefügt

  • ID 9d77db68ceb6b1ffa09ef544a39790d81e3f693f
  • Vorgänger 792d1a7c
  • Nachfolger b89e4677

Shop - Controller für ShopOrder

Bearbeitung von importierten Shop-Aufträgen

Unterschiede anzeigen:

SL/Controller/ShopOrder.pm
1
package SL::Controller::ShopOrder;
2

  
3
use strict;
4

  
5
use parent qw(SL::Controller::Base);
6

  
7
use SL::DB::ShopOrder;
8
use SL::DB::ShopOrderItem;
9
use SL::DB::Shop;
10
use SL::Shop;
11
use SL::Presenter;
12
use SL::Locale::String;
13
use SL::Controller::Helper::ParseFilter;
14
use Rose::Object::MakeMethods::Generic
15
(
16
  'scalar --get_set_init' => [ qw(shop_order transferred) ],
17
);
18
use Data::Dumper;
19

  
20
sub action_get_orders {
21
  my ( $self ) = @_;
22

  
23
  my $active_shops = SL::DB::Manager::Shop->get_all(query => [ obsolete => 0 ]);
24
  foreach my $shop_config ( @{ $active_shops } ) {
25
    my $shop = SL::Shop->new( config => $shop_config );
26
    my $new_orders = $shop->connector->get_new_orders;
27
  };
28
  $self->action_list;
29
}
30

  
31
sub action_list {
32
  my ( $self ) = @_;
33
  $::lxdebug->dump(0, "WH: LIST ", \$::form);
34
  my %filter = ($::form->{filter} ? parse_filter($::form->{filter}) : query => [ transferred => 0 ]);
35
  my $transferred = $::form->{filter}->{transferred_eq_ignore_empty} ne '' ? $::form->{filter}->{transferred_eq_ignore_empty} : '';
36
  #$::lxdebug->dump(0, "WH: FILTER ",  $::form->{filter}->{_eq_ignore_empty}." - ".$transferred);
37
  #$::lxdebug->dump(0, "WH: FILTER2 ",  \%filter);
38
  my $sort_by = $::form->{sort_by} ? $::form->{sort_by} : 'order_date';
39
  $sort_by .=$::form->{sort_dir} ? ' DESC' : ' ASC';
40
  my $shop_orders = SL::DB::Manager::ShopOrder->get_all( %filter, sort_by => $sort_by,
41
                                                      with_objects => ['shop_order_items'],
42
                                                    );
43
  $::lxdebug->dump(0, "WH: IMPORTS ",  \$shop_orders);
44
  $self->render('shop_order/list',
45
                title       => t8('ShopOrders'),
46
                SHOPORDERS  => $shop_orders,
47
                TOOK        => $transferred,  # is this used?
48
              );
49
}
50

  
51
sub action_show {
52
  my ( $self ) = @_;
53
  my $id = $::form->{id} || {};
54
  my $shop_order = SL::DB::Manager::ShopOrder->find_by( id => $id );
55
  die "can't find shoporder with id $id" unless $shop_order;
56

  
57
  # the different importaddresscheck if there complete in the customer table to prevent duplicats inserts
58
  my %customer_address = ( 'name'    => $shop_order->customer_lastname,
59
                           'company' => $shop_order->customer_company,
60
                           'street'  => $shop_order->customer_street,
61
                           'zipcode' => $shop_order->customer_zipcode,
62
                           'city'    => $shop_order->customer_city,
63
                         );
64
  my %billing_address = ( 'name'     => $shop_order->billing_lastname,
65
                          'company'  => $shop_order->billing_company,
66
                          'street'   => $shop_order->billing_street,
67
                          'zipcode'  => $shop_order->billing_zipcode,
68
                          'city'     => $shop_order->billing_city,
69
                        );
70
  my %delivery_address = ( 'name'    => $shop_order->delivery_lastname,
71
                           'company' => $shop_order->delivery_company,
72
                           'street'  => $shop_order->delivery_street,
73
                           'zipcode' => $shop_order->delivery_zipcode,
74
                           'city'    => $shop_order->delivery_city,
75
                         );
76
  my $c_address = $self->check_address(%customer_address);
77
  my $b_address = $self->check_address(%billing_address);
78
  my $d_address = $self->check_address(%delivery_address);
79
  ####
80

  
81
  my $lastname = $shop_order->customer_lastname;
82
  my $proposals = SL::DB::Manager::Customer->get_all(
83
       where => [
84
                   or => [
85
                            and => [ # when matching names also match zipcode
86
                                     or => [ 'name' => { like => "%$lastname%"},
87
                                             'name' => { like => $shop_order->customer_company },
88
                                           ],
89
                                     'zipcode' => { like => $shop_order->customer_zipcode },
90
                                   ],
91
                            or  => [ 'email' => { like => $shop_order->customer_email } ],
92
                         ],
93
                ],
94
  );
95

  
96
  $self->render('shop_order/show',
97
                title       => t8('Shoporder'),
98
                IMPORT      => $shop_order,
99
                PROPOSALS   => $proposals,
100
                C_ADDRESS   => $c_address,
101
                B_ADDRESS   => $b_address,
102
                D_ADDRESS   => $d_address,
103
              );
104

  
105
}
106

  
107
sub action_transfer {
108
  my ( $self ) = @_;
109
  my $customer = SL::DB::Manager::Customer->find_by(id => $::form->{customer});
110
  die "Can't find customer" unless $customer;
111
  my $employee = SL::DB::Manager::Employee->current;
112

  
113
  # $self->shop_order inits via $::form->{import_id}
114
  die "Can't load shop_order form form->import_id" unless $self->shop_order;
115

  
116
  my $order = $self->shop_order->convert_to_sales_order(customer => $customer, employee => $employee);
117
  $order->save;
118
  $self->shop_order->transferred(1);
119
  $self->shop_order->transfer_date(DateTime->now_local);
120
  $self->shop_order->oe_transid($order->id);
121
  $self->shop_order->save;
122
  $self->shop_order->link_to_record($order);
123
  $self->redirect_to(controller => "oe.pl", action => 'edit', type => 'sales_order', vc => 'customer', id => $order->id);
124
}
125

  
126
sub action_apply_customer {
127
  my ( $self ) = @_;
128
  $::lxdebug->dump(0, "WH: CUSTOMER ", \$::form);
129
  my $what = $::form->{create_customer}; # billing, customer or delivery
130
  $::lxdebug->dump(0, "WH: WHAT ",$what);
131
  my %address = ( 'name'       => $::form->{$what.'_name'},
132
                  'street'     => $::form->{$what.'_street'},
133
                  'zipcode'    => $::form->{$what.'_zipcode'},
134
                  'city'       => $::form->{$what.'_city'},
135
                  'email'      => $::form->{$what.'_email'},
136
                  'country'    => $::form->{$what.'_country'},
137
                  'greeting'   => $::form->{$what.'_greeting'},
138
                  'taxzone_id' => 4,  # hardcoded, use default taxzone instead
139
                  'currency'   => 1,  # hardcoded
140
                );
141
  $address{contact} = ($address{name} ne $::form->{$what.'_firstname'} . " " . $::form->{$what.'_lastname'} ? $::form->{$what.'_firstname'} . " " . $::form->{$what.'_lastname'} : '');
142
  $::lxdebug->dump(0, "WH: ADDRESS ",\%address);
143
  my $customer = SL::DB::Customer->new(%address);
144
  $customer->save;
145
  if($::form->{$what.'_country'} ne "Deutschland") {   # hardcoded
146
    $self->redirect_to(controller => "controller.pl", action => 'CustomerVendor/edit', id => $customer->id);
147
  }else{
148
    $self->redirect_to(action => 'show', id => $::form->{import_id});
149
  }
150
}
151
#
152
# Helper
153
#
154
sub check_address {
155
  my ($self,%address) = @_;
156
  my $addressdata = SL::DB::Manager::Customer->get_all(
157
                                query => [
158
                                            or => [ 'name'   => { like => "%$address{'name'}%" }, 'name' => { like => $address{'company'} }, ],
159
                                           'street' => { like => $address{'street'} },
160
                                           'zipcode'=> { like => $address{'zipcode'} },
161
                                           'city'   => { like => $address{'city'} },
162
                                         ]);
163
  $::lxdebug->dump(0, "WH: CUSTOMER ", \$addressdata);
164
  return @{$addressdata}[0];
165
}
166

  
167
sub init_shop_order {
168
  my ( $self ) = @_;
169
  return SL::DB::ShopOrder->new(id => $::form->{import_id})->load if $::form->{import_id};
170
}
171

  
172
sub init_transferred {
173
  # data for drop down filter options
174

  
175
  [ { title => t8("all"),             value => '' },
176
    { title => t8("transferred"),     value => 1  },
177
    { title => t8("not transferred"), value => 0  }, ]
178
}
179

  
180
1;
SL/DB/ShopOrder.pm
7 7

  
8 8
use SL::DB::MetaSetup::ShopOrder;
9 9
use SL::DB::Manager::ShopOrder;
10
use SL::DB::Helper::LinkedRecords;
10 11

  
11 12
__PACKAGE__->meta->add_relationships(
12 13
  shop_order_items => {
......
18 19

  
19 20
__PACKAGE__->meta->initialize;
20 21

  
22
sub convert_to_sales_order {
23
  my ($self, %params) = @_;
24

  
25
  my $customer = $params{customer};
26
  my $employee = $params{employee};
27
  die unless ref($customer) eq 'SL::DB::Customer';
28
  die unless ref($employee) eq 'SL::DB::Employee';
29

  
30
  require SL::DB::Order;
31
  require SL::DB::OrderItem;
32
  require SL::DB::Part;
33
  require SL::DB::Shipto;
34

  
35
  my @order_items;
36
  foreach my $items (@{$self->shop_order_items}) {
37
    my $item = SL::DB::OrderItem->new;
38
    my $part = SL::DB::Manager::Part->find_by( partnumber => $items->{partnumber} );
39

  
40
    $item->assign_attributes(
41
        parts_id        => $part->id,
42
        description     => $items->description,
43
        qty             => $items->quantity,
44
        sellprice       => $items->price,
45
        unit            => $part->unit,
46
        );
47
    push(@order_items,$item);
48
  }
49

  
50
  my $shipto_id;
51
  if ($self->{billing_firstname} ne $self->{delivery_firstname} || $self->{billing_lastname} ne $self->{delivery_lastname} || $self->{billing_city} ne $self->{delivery_city} || $self->{billing_street} ne $self->{delivery_street}) {
52
    if(my $address = SL::DB::Manager::Shipto->find_by( shiptoname          => $self->{delivery_firstname} . " " . $self->{delivery_lastname}, 
53
                                                        shiptostreet        => $self->{delivery_street},
54
                                                        shiptocity          => $self->{delivery_city},
55
                                                      )) {
56
      $shipto_id = $address->{shipto_id};
57
    } else {
58
      my $gender = $self->{delivery_greeting} eq "Frau" ? 'f' : 'm';
59
      my $deliveryaddress = SL::DB::Shipto->new;
60
      $deliveryaddress->assign_attributes(
61
        shiptoname      => $self->{delivery_firstname} . " " . $self->{delivery_lastname},
62
        shiptocp_gender => $gender,
63
        shiptostreet    => $self->{delivery_street},
64
        shiptozipcode   => $self->{delivery_zipcode},
65
        shiptocity      => $self->{delivery_city},
66
        shiptocountry   => $self->{delivery_country},
67
        trans_id        => $customer->id,   # ????
68
        module          => "CT",
69
      );
70
      $deliveryaddress->save;
71
      $shipto_id = $deliveryaddress->{shipto_id};
72
    }
73
  }
74

  
75
  my $order = SL::DB::Order->new(
76
                  amount                  => $self->amount,
77
                  cusordnumber            => $self->shop_id,
78
                  customer_id             => $customer->id,
79
                  shipto_id               => $shipto_id,
80
                  orderitems              => [ @order_items ],
81
                  employee_id             => $employee->id,
82
                  intnotes                => $self->{shop_customer_comment},
83
                  salesman_id             => $employee->id,
84
                  taxincluded             => 1,   # TODO: make variable
85
                  taxzone_id              => $customer->taxzone_id,
86
                  currency_id             => $customer->currency_id,
87
                  transaction_description => 'Shop Import',
88
                  transdate               => DateTime->today_local
89
                );
90
  # $order->save;
91
  return $order;
92
};
93

  
21 94
1;
templates/webpages/shop_order/_filter.html
1
[%- USE T8 %]
2
[%- USE L %]
3
[%- USE LxERP %]
4
[%- USE HTML %]
5
<form action='controller.pl' method='post'>
6
 [% L.submit_tag('action_get_orders',LxERP.t8('New shop orders')) %]
7
 <table id='filter_table'>
8

  
9
    <tr>
10
     <th align="right">[% 'Status' | $T8 %]</th>
11
     <td>[% L.select_tag('filter.transferred:eq_ignore_empty', SELF.transferred, value_key = 'value', title_key = 'title', default=TOOK) %]</td>
12
    </tr>
13

  
14

  
15
    <tr>
16
     <th align="right">[% 'from' | $T8 %]</th>
17
     <td>[% L.date_tag('filter.order_date:date::ge', filter.order_date_date__ge) %]</td>
18
    </tr>
19

  
20
    <tr>
21
     <th align="right">[% 'to' | $T8 %]</th>
22
     <td>[% L.date_tag('filter.order_date:date::le', filter.order_date_date__le) %]</td>
23
    </tr>
24

  
25
 </table>
26

  
27

  
28
<a href='#' onClick='javascript:$("#filter_table input").val("");$("#filter_table input[type=checkbox]").prop("checked", 0);'>[% 'Reset' | $T8 %]</a>
29
<br>
30

  
31
 [% L.hidden_tag('action', 'ShopOrder/dispatch') %]
32
 [% L.submit_tag('action_list',LxERP.t8('renew')) %]
33

  
34
</form>
templates/webpages/shop_order/list.html
1
[%- USE HTML -%][%- USE LxERP -%][%- USE L -%][%- USE T8 -%]
2
[% USE Dumper %]
3

  
4
<h1>[% title %]</h1>
5
[%- PROCESS 'shop_order/_filter.html' filter=SELF.models.filtered.laundered %]
6
<hr>
7
 <table id="shoplist">
8
  <thead>
9
   <tr class="listheading">
10
    <th>[% 'Shop Host' | $T8 %]</th>
11
    <th>[% IF FORM.sort_by == 'order_date' %]
12
      <a href ="controller.pl?action=ShopOrder/list&filter.transferred:eq_ignore_empty=[% FORM.filter.transferred_eq_ignore_empty %]&sort_by=order_date&sort_dir=[% 1 - FORM.sort_dir %]" class="sort_link">
13
        [% 'Shop orderdate' | $T8 %][% IF FORM.sort_dir == 0 %]<img border="0" src="image/down.png">[% ELSE %]<img border="0" src="image/up.png">[% END %]</a>
14
    [% ELSE %]
15
      <a href ="controller.pl?action=ShopOrder/list&filter.transferred:eq_ignore_empty=[% FORM.filter.transferred_eq_ignore_empty %]&sort_by=order_date&sort_dir=0" class="sort_link">
16
        [% 'Shop orderdate' | $T8 %]</a>
17
    [% END %]
18
    </th>
19
    <th>[% IF FORM.sort_by == 'shop_ordernumber' %]
20
      <a href ="controller.pl?action=ShopOrder/list&filter.transferred:eq_ignore_empty=[% FORM.filter.transferred_eq_ignore_empty %]&sort_by=shop_ordernumber&sort_dir=[% 1 - FORM.sort_dir %]" class="sort_link">
21
        [% 'Shop ordernumber' | $T8 %][% IF FORM.sort_dir == 0 %]<img border="0" src="image/down.png">[% ELSE %]<img border="0" src="image/up.png">[% END %]</a>
22
    [% ELSE %]
23
      <a href ="controller.pl?action=ShopOrder/list&filter.transferred:eq_ignore_empty=[% FORM.filter.transferred_eq_ignore_empty %]&sort_by=shop_ordernumber&sort_dir=0" class="sort_link">
24
        [% 'Shop ordernumber' | $T8 %]</a>
25
    [% END %]
26
    </th>
27
    <th>[% IF FORM.sort_by == 'shop_customer_number' %]
28
      <a href ="controller.pl?action=ShopOrder/list&filter.transferred:eq_ignore_empty=[% FORM.filter.transferred_eq_ignore_empty %]&sort_by=shop_customer_number&sort_dir=[% 1 - FORM.sort_dir %]" class="sort_link">
29
        [% 'Shop customernumber' | $T8 %][% IF FORM.sort_dir == 0 %]<img border="0" src="image/down.png">[% ELSE %]<img border="0" src="image/up.png">[% END %]</a>
30
    [% ELSE %]
31
      <a href ="controller.pl?action=ShopOrder/list&filter.transferred:eq_ignore_empty=[% FORM.filter.transferred_eq_ignore_empty %]&sort_by=shop_customer_number&sort_dir=0" class="sort_link">
32
        [% 'Shop customernumber' | $T8 %]</a>
33
    [% END %]
34
    </th>
35
    <th>[% 'Shop Customer Address' | $T8 %]<br>
36
    [% IF FORM.sort_by == 'customer_lastname' %]
37
      <a href ="controller.pl?action=ShopOrder/list&filter.transferred:eq_ignore_empty=[% FORM.filter.transferred_eq_ignore_empty %]&sort_by=customer_lastname&sort_dir=[% 1 - FORM.sort_dir %]" class="sort_link">
38
        [% 'Name' | $T8 %][% IF FORM.sort_dir == 0 %]<img border="0" src="image/down.png">[% ELSE %]<img border="0" src="image/up.png">[% END %]</a>|
39
    [% ELSE %]
40
      <a href ="controller.pl?action=ShopOrder/list&filter.transferred:eq_ignore_empty=[% FORM.filter.transferred_eq_ignore_empty %]&sort_by=customer_lastname&sort_dir=0" class="sort_link">
41
        [% 'Name' | $T8 %]</a>|
42
    [% END %]
43
    [% IF FORM.sort_by == 'customer_zipcode' %]
44
      <a href ="controller.pl?action=ShopOrder/list&filter.transferred:eq_ignore_empty=[% FORM.filter.transferred_eq_ignore_empty %]&sort_by=customer_zipcode&sort_dir=[% 1 - FORM.sort_dir %]" class="sort_link">
45
        [% 'Zip' | $T8 %][% IF FORM.sort_dir == 0 %]<img border="0" src="image/down.png">[% ELSE %]<img border="0" src="image/up.png">[% END %]</a>|
46
    [% ELSE %]
47
      <a href ="controller.pl?action=ShopOrder/list&filter.transferred:eq_ignore_empty=[% FORM.filter.transferred_eq_ignore_empty %]&sort_by=customer_zipcode&sort_dir=0" class="sort_link">
48
        [% 'Zip' | $T8 %]</a>|
49
    [% END %]
50
    [% IF FORM.sort_by == 'customer_country' %]
51
      <a href ="controller.pl?action=ShopOrder/list&filter.transferred:eq_ignore_empty=[% FORM.filter.transferred_eq_ignore_empty %]&sort_by=customer_country&sort_dir=[% 1 - FORM.sort_dir %]" class="sort_link">
52
        [% 'Country' | $T8 %][% IF FORM.sort_dir == 0 %]<img border="0" src="image/down.png">[% ELSE %]<img border="0" src="image/up.png">[% END %]</a>
53
    [% ELSE %]
54
      <a href ="controller.pl?action=ShopOrder/list&filter.transferred:eq_ignore_empty=[% FORM.filter.transferred_eq_ignore_empty %]&sort_by=customer_country&sort_dir=0" class="sort_link">
55
        [% 'Country' | $T8 %]</a>
56
    [% END %]
57
      </th>
58
    <th>[% 'Shop Billing Address' | $T8 %]</br>
59
    [% IF FORM.sort_by == 'billing_lastname' %]
60
      <a href ="controller.pl?action=ShopOrder/list&filter.transferred:eq_ignore_empty=[% FORM.filter.transferred_eq_ignore_empty %]&sort_by=billing_lastname&sort_dir=[% 1 - FORM.sort_dir %]" class="sort_link">
61
        [% 'Name' | $T8 %][% IF FORM.sort_dir == 0 %]<img border="0" src="image/down.png">[% ELSE %]<img border="0" src="image/up.png">[% END %]</a>|
62
    [% ELSE %]
63
      <a href ="controller.pl?action=ShopOrder/list&filter.transferred:eq_ignore_empty=[% FORM.filter.transferred_eq_ignore_empty %]&sort_by=billing_lastname&sort_dir=0" class="sort_link">
64
        [% 'Name' | $T8 %]</a>|
65
    [% END %]
66
    [% IF FORM.sort_by == 'billing_zipcode' %]
67
      <a href ="controller.pl?action=ShopOrder/list&filter.transferred:eq_ignore_empty=[% FORM.filter.transferred_eq_ignore_empty %]&sort_by=billing_zipcode&sort_dir=[% 1 - FORM.sort_dir %]" class="sort_link">
68
        [% 'Zip' | $T8 %][% IF FORM.sort_dir == 0 %]<img border="0" src="image/down.png">[% ELSE %]<img border="0" src="image/up.png">[% END %]</a>|
69
    [% ELSE %]
70
      <a href ="controller.pl?action=ShopOrder/list&filter.transferred:eq_ignore_empty=[% FORM.filter.transferred_eq_ignore_empty %]&sort_by=billing_zipcode&sort_dir=0" class="sort_link">
71
        [% 'Zip' | $T8 %]</a>|
72
    [% END %]
73
    [% IF FORM.sort_by == 'billing_country' %]
74
      <a href ="controller.pl?action=ShopOrder/list&filter.transferred:eq_ignore_empty=[% FORM.filter.transferred_eq_ignore_empty %]&sort_by=billing_country&sort_dir=[% 1 - FORM.sort_dir %]" class="sort_link">
75
        [% 'Country' | $T8 %][% IF FORM.sort_dir == 0 %]<img border="0" src="image/down.png">[% ELSE %]<img border="0" src="image/up.png">[% END %]</a>
76
    [% ELSE %]
77
      <a href ="controller.pl?action=ShopOrder/list&filter.transferred:eq_ignore_empty=[% FORM.filter.transferred_eq_ignore_empty %]&sort_by=billing_country&sort_dir=0" class="sort_link">
78
        [% 'Country' | $T8 %]</a>
79
    [% END %]
80
      </th>
81
    <th>[% 'Shop Delivery Address' | $T8 %]</br>
82
    [% IF FORM.sort_by == 'delivery_lastname' %]
83
      <a href ="controller.pl?action=ShopOrder/list&filter.transferred:eq_ignore_empty=[% FORM.filter.transferred_eq_ignore_empty %]&sort_by=delivery_lastname&sort_dir=[% 1 - FORM.sort_dir %]" class="sort_link">
84
        [% 'Name' | $T8 %][% IF FORM.sort_dir == 0 %]<img border="0" src="image/down.png">[% ELSE %]<img border="0" src="image/up.png">[% END %]</a>|
85
    [% ELSE %]
86
      <a href ="controller.pl?action=ShopOrder/list&filter.transferred:eq_ignore_empty=[% FORM.filter.transferred_eq_ignore_empty %]&sort_by=delivery_lastname&sort_dir=0" class="sort_link">
87
        [% 'Name' | $T8 %]</a>|
88
    [% END %]
89
    [% IF FORM.sort_by == 'delivery_zipcode' %]
90
      <a href ="controller.pl?action=ShopOrder/list&filter.transferred:eq_ignore_empty=[% FORM.filter.transferred_eq_ignore_empty %]&sort_by=delivery_zipcode&sort_dir=[% 1 - FORM.sort_dir %]" class="sort_link">
91
        [% 'Zip' | $T8 %][% IF FORM.sort_dir == 0 %]<img border="0" src="image/down.png">[% ELSE %]<img border="0" src="image/up.png">[% END %]</a>|
92
    [% ELSE %]
93
      <a href ="controller.pl?action=ShopOrder/list&filter.transferred:eq_ignore_empty=[% FORM.filter.transferred_eq_ignore_empty %]&sort_by=delivery_zipcode&sort_dir=0" class="sort_link">
94
        [% 'Zip' | $T8 %]</a>|
95
    [% END %]
96
    [% IF FORM.sort_by == 'delivery_country' %]
97
      <a href ="controller.pl?action=ShopOrder/list&filter.transferred:eq_ignore_empty=[% FORM.filter.transferred_eq_ignore_empty %]&sort_by=delivery_country&sort_dir=[% 1 - FORM.sort_dir %]" class="sort_link">
98
        [% 'Country' | $T8 %][% IF FORM.sort_dir == 0 %]<img border="0" src="image/down.png">[% ELSE %]<img border="0" src="image/up.png">[% END %]</a>
99
    [% ELSE %]
100
      <a href ="controller.pl?action=ShopOrder/list&filter.transferred:eq_ignore_empty=[% FORM.filter.transferred_eq_ignore_empty %]&sort_by=delivery_country&sort_dir=0" class="sort_link">
101
        [% 'Country' | $T8 %]</a>
102
    [% END %]
103
      </th>
104
    <th>[% IF FORM.sort_by == 'shop_customer_comment' %]
105
      <a href ="controller.pl?action=ShopOrder/list&filter.transferred:eq_ignore_empty=[% FORM.filter.transferred_eq_ignore_empty %]&sort_by=shop_customer_comment&sort_dir=[% 1 - FORM.sort_dir %]" class="sort_link">
106
        [% 'Notes' | $T8 %][% IF FORM.sort_dir == 0 %]<img border="0" src="image/down.png">[% ELSE %]<img border="0" src="image/up.png">[% END %]</a>
107
    [% ELSE %]
108
      <a href ="controller.pl?action=ShopOrder/list&filter.transferred:eq_ignore_empty=[% FORM.filter.transferred_eq_ignore_empty %]&sort_by=shop_customer_comment&sort_dir=0" class="sort_link">
109
        [% 'Notes' | $T8 %]</a>
110
    [% END %]
111
    </th>
112
    <th>
113
      [% 'Positions' | $T8 %]<br>
114
      [% IF FORM.sort_by == 'amount' %]
115
      <a href ="controller.pl?action=ShopOrder/list&filter.transferred:eq_ignore_empty=[% FORM.filter.transferred_eq_ignore_empty %]&sort_by=amount&sort_dir=[% 1 - FORM.sort_dir %]" class="sort_link">
116
        [% 'Amount' | $T8 %][% IF FORM.sort_dir == 0 %]<img border="0" src="image/down.png">[% ELSE %]<img border="0" src="image/up.png">[% END %]</a>
117
      [% ELSE %]
118
      <a href ="controller.pl?action=ShopOrder/list&filter.transferred:eq_ignore_empty=[% FORM.filter.transferred_eq_ignore_empty %]&sort_by=amount&sort_dir=0" class="sort_link"> [% 'Amount' | $T8 %]</a><br>
119
      [% END %]
120
      [% IF FORM.sort_by == 'shipping_costs' %]
121
      <a href ="controller.pl?action=ShopOrder/list&filter.transferred:eq_ignore_empty=[% FORM.filter.transferred_eq_ignore_empty %]&sort_by=shipping_costs&sort_dir=[% 1 - FORM.sort_dir %]" class="sort_link">
122
        [% 'Shippingcosts' | $T8 %][% IF FORM.sort_dir == 0 %]<img border="0" src="image/down.png">[% ELSE %]<img border="0" src="image/up.png">[% END %]</a>
123
      [% ELSE %]
124
      <a href ="controller.pl?action=ShopOrder/list&filter.transferred:eq_ignore_empty=[% FORM.filter.transferred_eq_ignore_empty %]&sort_by=shipping_costs&sort_dir=0" class="sort_link"> [% 'Shippingcosts' | $T8 %]</a><br>
125
      [% END %]
126
    </th>
127
    <th></th>
128
   </tr>
129
  </thead>
130
  [% FOREACH shop_order = SHOPORDERS %]
131
  <tr class="listrow">
132
    <td>[% HTML.escape(shop_order.host) %]</td>
133
    <td>[% shop_order.order_date.dmy('.') _ ' ' _ shop_order.order_date.hms(':') %]</td>
134
    <td>[% HTML.escape(shop_order.shop_ordernumber) %]</td>
135
    <td>[% HTML.escape(shop_order.shop_customer_number) %]</td>
136
    <td>[% IF shop_order.customer_company %]<b>[% HTML.escape(shop_order.customer_company) %]</b><br>[% END %]
137
      <b>[% HTML.escape(shop_order.customer_lastname) %],&nbsp;[% HTML.escape(shop_order.customer_firstname) %]</b>
138
      <br>[% HTML.escape(shop_order.customer_street) %]
139
      <br>[% HTML.escape(shop_order.customer_zipcode) %]&nbsp;[% HTML.escape(shop_order.customer_city) %]
140
      <br>[% HTML.escape(shop_order.customer_country) %] </td>
141
    <td>[% IF shop_order.customer_company %]<b>[% HTML.escape(shop_order.customer_company) %]</b><br>[% END %]
142
      <b>[% HTML.escape(shop_order.billing_lastname) %],&nbsp;[% HTML.escape(shop_order.billing_firstname) %]</b>
143
      <br>[% HTML.escape(shop_order.billing_street) %]
144
      <br>[% HTML.escape(shop_order.billing_zipcode) %]&nbsp;[% HTML.escape(shop_order.billing_city) %]
145
      <br>[% HTML.escape(shop_order.billing_country) %] </td>
146
    [% IF (shop_order.delivery_lastname != shop_order.billing_lastname || shop_order.delivery_firstname != shop_order.billing_firstname || shop_order.delivery_street != shop_order.billing_street || shop_order.delivery_city != shop_order.billing_city) %] [% SET deliveryclass = 'style="background-color:red;"' %] [% ELSE %] [% SET deliveryclass = '' %] [% END %]
147
    <td [% deliveryclass %]>[% IF shop_order.customer_company %]<b>[% HTML.escape(shop_order.customer_company) %]</b><br>[% END %]
148
      <b>[% HTML.escape(shop_order.delivery_lastname) %],&nbsp;[% HTML.escape(shop_order.delivery_firstname) %]</b>
149
      <br>[% HTML.escape(shop_order.delivery_street) %]
150
      <br>[% HTML.escape(shop_order.delivery_zipcode) %]&nbsp;[% HTML.escape(shop_order.delivery_city) %]
151
      <br>[% HTML.escape(shop_order.delivery_country) %] </td>
152
    <td>[% HTML.escape(shop_order.shop_customer_comment) %]</td>
153
    <td>[% shop_order.shop_order_items.size %]<br>[% shop_order.amount_as_number %]<br>[% shop_order.shipping_costs_as_number %]</td>
154
    <td>[% IF shop_order.transferred == 1 %]<a href="controller.pl?id=[% shop_order.id %]&action=ShopOrder/show">[% 'Show order' | $T8 %]<br>[% shop_order.transferred_date_as_date %]</a>
155
        [% ELSE %]<a href="controller.pl?id=[% shop_order.id %]&action=ShopOrder/show">[% 'Create order' | $T8 %][% END %]</a></td>
156
  </tr>
157
  [% END %]
158
 </table>
templates/webpages/shop_order/show.html
1
[%- USE HTML -%][%- USE LxERP -%][%- USE L -%][%- USE T8 -%]
2
[% L.stylesheet_tag('webshop') %]
3

  
4
<h1>[% title %]</h1>
5

  
6
<form method="post" action="controller.pl">
7
  <div class="table main">
8
    <div class="table-row listheading">
9
      <div class="table-cell">
10
        <div class="table" style="margin:150px,15px,15px,15px;">
11
          <div class="table-row listheading">
12
            <div class="table-cell">[% 'Shop Customer Address' | $T8 %]</div>
13
          </div>
14
          <div class="table-row"><div class="table-cell">[% 'Greeting' | $T8 %]</div><div class="table-cell">[% L.input_tag('customer_greeting', IMPORT.customer_greeting) %]</div></div>
15
          <div class="table-row"><div class="table-cell">[% 'Firstname' | $T8 %]</div><div class="table-cell">[% L.input_tag('customer_firstname', IMPORT.customer_firstname) %]</div></div>
16
          <div class="table-row"><div class="table-cell">[% 'Lastname' | $T8 %]</div><div class="table-cell">[% L.input_tag('customer_lastname', IMPORT.customer_lastname) %]</div></div>
17
          <div class="table-row"><div class="table-cell">[% 'Company' | $T8 %]</div><div class="table-cell">[% L.input_tag('customer_company', IMPORT.customer_company) %]</div></div>
18
          [% IF IMPORT.customer_company == '' %]
19
            [% SET customer = IMPORT.customer_firstname _ ' ' _ IMPORT.customer_lastname %]
20
          [% ELSE %]
21
            [% SET customer = IMPORT.customer_company %]
22
          [% END %]
23
          <hr>
24
          <div class="table-row"><div class="table-cell">[% 'Customer' | $T8 %]</div><div class="table-cell">[% L.input_tag('customer_name', customer) %]</div></div>
25
          <div class="table-row"><div class="table-cell">[% 'Street' | $T8 %]</div><div class="table-cell">[% L.input_tag('customer_street', IMPORT.customer_street) %]</div></div>
26
          <div class="table-row"><div class="table-cell">[% 'Zipcode' | $T8 %]</div><div class="table-cell">[% L.input_tag('customer_zipcode', IMPORT.customer_zipcode) %]</div></div>
27
          <div class="table-row"><div class="table-cell">[% 'City' | $T8 %]</div><div class="table-cell">[% L.input_tag('customer_city', IMPORT.customer_city) %]</div></div>
28
          <div class="table-row"><div class="table-cell">[% 'Country' | $T8 %]</div><div class="table-cell">[% L.input_tag('customer_country', IMPORT.customer_country) %]</div></div>
29
          <div class="table-row"><div class="table-cell">[% 'Email' | $T8 %]</div><div class="table-cell">[% L.input_tag('customer_email', IMPORT.customer_email) %]</div></div>
30
          [% IF C_ADDRESS %]
31
          <div>[% C_ADDRESS.customernumber %]</div>
32
          [% ELSE %]
33
          <div>[% L.radio_button_tag('create_customer', value='customer') %]</div>
34
          [% END %]
35
        </div>
36
      </div>
37
      <div class="table-cell">
38
        <div class="table">
39
          <div class="table-row listheading">
40
            <div class="table-cell">[% 'Shop Billing  Address' | $T8 %]</div>
41
          </div>
42
          <div class="table-row"><div class="table-cell">[% 'Greeting' | $T8 %]</div><div class="table-cell">[% L.input_tag('billing_greeting', IMPORT.billing_greeting) %]</div></div>
43
          <div class="table-row"><div class="table-cell">[% 'Firstname' | $T8 %]</div><div class="table-cell">[% L.input_tag('billing_firstname', IMPORT.billing_firstname) %]</div></div>
44
          <div class="table-row"><div class="table-cell">[% 'Lastname' | $T8 %]</div><div class="table-cell">[% L.input_tag('billing_lastname', IMPORT.billing_lastname) %]</div></div>
45
          <div class="table-row"><div class="table-cell">[% 'Company' | $T8 %]</div><div class="table-cell">[% L.input_tag('billing_company', IMPORT.billing_company) %]</div></div>
46
          [% IF IMPORT.billing_company == '' %]
47
            [% SET billing = IMPORT.billing_firstname _ ' ' _ IMPORT.billing_lastname %]
48
          [% ELSE %]
49
            [% SET billing = IMPORT.billing_company %]
50
          [% END %]
51
          <hr>
52
          <div class="table-row"><div class="table-cell">[% 'Customer' | $T8 %]</div><div class="table-cell">[% L.input_tag('billing_name', billing) %]</div></div>
53
          <div class="table-row"><div class="table-cell">[% 'Street' | $T8 %]</div><div class="table-cell">[% L.input_tag('billing_street', IMPORT.billing_street) %]</div></div>
54
          <div class="table-row"><div class="table-cell">[% 'Zipcode' | $T8 %]</div><div class="table-cell">[% L.input_tag('billing_zipcode', IMPORT.billing_zipcode) %]</div></div>
55
          <div class="table-row"><div class="table-cell">[% 'City' | $T8 %]</div><div class="table-cell">[% L.input_tag('billing_city', IMPORT.billing_city) %]</div></div>
56
          <div class="table-row"><div class="table-cell">[% 'Country' | $T8 %]</div><div class="table-cell">[% L.input_tag('billing_country', IMPORT.billing_country) %]</div></div>
57
          <div class="table-row"><div class="table-cell">[% 'Email' | $T8 %]</div><div class="table-cell">[% L.input_tag('billing_email', IMPORT.billing_email) %]</div></div>
58
          [% IF B_ADDRESS %]
59
          <div>[% B_ADDRESS.customernumber %]</div>
60
          [% ELSE %]
61
          <div>[% L.radio_button_tag('create_customer', value='billing') %]</div>
62
          [% END %]
63
        </div>
64
      </div>
65
      <div class="table-cell">
66
        <div style="display:table;">
67
          <div class="table-row listheading">
68
            <div class="table-cell">[% 'Shop Delivery Address' | $T8 %]</div>
69
          </div>
70
          <div class="table-row"><div class="table-cell">[% 'Greeting' | $T8 %]</div><div class="table-cell">[% L.input_tag('delivery_greeting', IMPORT.billing_greeting) %]</div></div>
71
          <div class="table-row"><div class="table-cell">[% 'Firstname' | $T8 %]</div><div class="table-cell">[% L.input_tag('delivery_firstname', IMPORT.delivery_firstname) %]</div></div>
72
          <div class="table-row"><div class="table-cell">[% 'Lastname' | $T8 %]</div><div class="table-cell">[% L.input_tag('delivery_lastname', IMPORT.delivery_lastname) %]</div></div>
73
          <div class="table-row"><div class="table-cell">[% 'Company' | $T8 %]</div><div class="table-cell">[% L.input_tag('delivery_company', IMPORT.delivery_company) %]</div></div>
74
          [% IF IMPORT.delivery_company == '' %]
75
            [% SET delivery = IMPORT.delivery_firstname _ ' ' _ IMPORT.delivery_lastname %]
76
          [% ELSE %]
77
            [% SET delivery = IMPORT.delivery_company %]
78
          [% END %]
79
          <hr>
80
          <div class="table-row"><div class="table-cell">[% 'Customer' | $T8 %]</div><div class="table-cell">[% L.input_tag('delivery_name', delivery) %]</div></div>
81
          <div class="table-row"><div class="table-cell">[% 'Street' | $T8 %]</div><div class="table-cell">[% L.input_tag('delivery_street', IMPORT.delivery_street) %]</div></div>
82
          <div class="table-row"><div class="table-cell">[% 'Zipcode' | $T8 %]</div><div class="table-cell">[% L.input_tag('delivery_zipcode', IMPORT.delivery_zipcode) %]</div></div>
83
          <div class="table-row"><div class="table-cell">[% 'City' | $T8 %]</div><div class="table-cell">[% L.input_tag('delivery_city', IMPORT.delivery_city) %]</div></div>
84
          <div class="table-row"><div class="table-cell">[% 'Country' | $T8 %]</div><div class="table-cell">[% L.input_tag('delivery_country', IMPORT.delivery_country) %]</div></div>
85
          <div class="table-row"><div class="table-cell">[% 'Email' | $T8 %]</div><div class="table-cell">[% L.input_tag('delivery_email', IMPORT.delivery_email) %]</div></div>
86
          [% IF D_ADDRESS %]
87
          <div>[% D_ADDRESS.customernumber %]</div>
88
          [% ELSE %]
89
          <div>[% L.radio_button_tag('create_customer', value='delivery') %]</div>
90
          <div>[% L.submit_tag('action_apply_customer', LxERP.t8('Create customer')) %]</div>
91
          [% END %]
92
        </div>
93
      </div>
94
    </div>
95
  </div>
96
  <hr>
97
  <table width="100%">
98
    <tr>
99
      <td width="35%">
100
        <table>
101
          <tr class="listheading">
102
            <th colspan="2">[% 'Shop Headdata' | $T8 %]</th>
103
          </tr>
104
          <tr><td><b>[% 'Shop Ordernumber' | $T8 %]</b></td><td>[% HTML.escape(IMPORT.shop_ordernumber) %]</td></tr>
105
          <tr><td><b>[% 'Shop Orderdate' | $T8 %]</b></td><td>[% HTML.escape(IMPORT.order_date.dmy('.')) _ ' ' _ HTML.escape(IMPORT.order_date.hms(':')) %]</td></tr>
106
          <tr><td><b>[% 'Shop Host' | $T8 %]</b></td><td>[% HTML.escape(IMPORT.host) %]</td></tr>
107
          <tr><td><b>[% 'Shop OrderIP' | $T8 %]</b></td><td>[% HTML.escape(IMPORT.remote_ip) %]</td></tr>
108
          <tr><td><b>[% 'Shop Ordernotes' | $T8 %]</b></td><td>[% HTML.escape(IMPORT.shop_customer_comment) %]</td></tr>
109
          <tr><td><b>[% 'Shop Orderamount' | $T8 %]</b></td><td>[% HTML.escape(IMPORT.amount_as_number) %]</td></tr>
110
          <tr><td><b>[% 'Shipping costs' | $T8 %]</b></td><td>[% HTML.escape(IMPORT.shipping_costs_as_number) %]</td></tr>
111
        </table>
112
      </td>
113
      <td style="padding-left: 20px; vertical-align: top;">
114
        [% UNLESS IMPORT.tranferred %]
115
        [% IF PROPOSALS %]
116
        <div style="height: 120px; overflow:auto;">
117
          <table>
118
            <tr class="listheading">
119
              <th colspan="7">Customer Proposals</td>
120
            </tr>
121
            [% FOREACH prop = PROPOSALS %]
122
            <tr>
123
              <td>[% L.radio_button_tag('customer', value=prop.id) %]</td>
124
              <td>[% HTML.escape(prop.customernumber) %]</td>
125
              <td>[% HTML.escape(prop.name) %]</td>
126
              <td>[% HTML.escape(prop.street) %]</td>
127
              <td>[% HTML.escape(prop.zipcode) %]</td>
128
              <td>[% HTML.escape(prop.city) %]</td>
129
              <td>[% HTML.escape(prop.email) %]</td>
130
            </tr>
131
            [% END %]
132
          </table>
133
       [% END # PROPOSALS %]
134
        </div>
135
        [% L.hidden_tag('action', 'ShopOrder/dispatch') %]
136
        [% L.hidden_tag('import_id', IMPORT.id) %]
137
        [%- L.submit_tag('action_transfer', LxERP.t8('Create order')) %]
138
       [% ELSE %]
139
        <div>
140
          Wurde schon übernommen
141
        </div>
142
        [% END %]
143
      </td>
144
    </tr>
145
  </table>
146
  <hr>
147
  <div style="height: 250px; overflow:auto; margin:15px;">
148
    <table width="99%">
149
      <tr class="listheading">
150
        <th>[% 'Position' | $T8 %]</th>
151
        <th>[% 'Partnumber' | $T8 %]</th>
152
        <th>[% 'Partdescriptipion' | $T8 %]</th>
153
        <th>[% 'Qty' | $T8 %]</th>
154
        <th>[% 'Price' | $T8 %]</th>
155
        <th>[% 'Extended' | $T8 %]</th>
156
      </tr>
157
      [% SET counter = 1 %]
158
      [% FOREACH pos = IMPORT.shop_order_items %]
159
      <tr class="listrow">
160
        <td>[% counter %]</td>
161
        <td>[% HTML.escape(pos.partnumber) %]</td>
162
        <td>[% HTML.escape(pos.description) %]</td>
163
        <td>[% pos.quantity_as_number%]</td>
164
        <td>[% pos.price_as_number%]</td>
165
        [% SET extended = pos.price * pos.quantity %]
166
        <td>[% LxERP.format_amount(extended,2) %]</td>
167
      </tr>
168
      [% SET counter = counter + 1 %]
169
      [% END %]
170
    </table>
171
  </div>
172
  <hr>
173
</form>
174
<script type="text/javascript">
175
  function apply_customer(address) {
176
    alert('Hallo ' + address);
177
    $.post("controller.pl", { action: 'ShopOrder/list'});
178
  }
179
</script>
180
[% L.dump(IMPORT) %] 

Auch abrufbar als: Unified diff