Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 11d2ae57

Von Werner Hahn vor etwa 7 Jahren hinzugefügt

  • ID 11d2ae5772060a0426dc8722dfe69bf2c6aeceea
  • Vorgänger 4e9e467a
  • Nachfolger 45c3c24a

WebshopApi: ShopOrder Controller

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::BackgroundJob::ShopOrderMassTransfer;
8
use SL::System::TaskServer;
9
use SL::DB::ShopOrder;
10
use SL::DB::ShopOrderItem;
11
use SL::DB::Shop;
12
use SL::DB::History;
13
use SL::DBUtils;
14
use SL::Shop;
15
use SL::Presenter;
16
use SL::Helper::Flash;
17
use SL::Locale::String;
18
use SL::Controller::Helper::ParseFilter;
19
use Rose::Object::MakeMethods::Generic
20
(
21
  'scalar --get_set_init' => [ qw(shop_order shops transferred js) ],
22
);
23

  
24
__PACKAGE__->run_before('check_auth');
25
__PACKAGE__->run_before('setup');
26

  
27
use Data::Dumper;
28

  
29
sub action_get_orders {
30
  my ( $self ) = @_;
31
  my $orders_fetched;
32
  my $new_orders;
33
  my %new_order;
34
  my $active_shops = SL::DB::Manager::Shop->get_all(query => [ obsolete => 0 ]);
35
  foreach my $shop_config ( @{ $active_shops } ) {
36
    my $shop = SL::Shop->new( config => $shop_config );
37
    my $connect = $shop->check_connectivity;
38

  
39
    if( !$connect->{success} ){
40
      %new_order  = (
41
        number_of_orders => $connect->{data}->{version},
42
        shop_id          => $shop->config->description,
43
        error            => 1,
44
     );
45
     $new_orders = \%new_order;
46
    }else{
47
      $new_orders = $shop->connector->get_new_orders;
48
    }
49
    push @{ $orders_fetched }, $new_orders ;
50
  }
51

  
52
  foreach my $shop_fetched(@{ $orders_fetched }) {
53
    if($shop_fetched->{error}){
54
      flash_later('error', t8('From shop "#1" :  #2 ', $shop_fetched->{shop_id}, $shop_fetched->{number_of_orders},));
55
    }else{
56
      flash_later('info', t8('From shop #1 :  #2 shoporders have been fetched.', $shop_fetched->{shop_id}, $shop_fetched->{number_of_orders},));
57
    }
58
  }
59
  $self->redirect_to(controller => "ShopOrder", action => 'list');
60
}
61

  
62
sub action_list {
63
  my ( $self ) = @_;
64

  
65
  my %filter = ($::form->{filter} ? parse_filter($::form->{filter}) : query => [ transferred => 0, obsolete => 0 ]);
66
  my $transferred = $::form->{filter}->{transferred_eq_ignore_empty} ne '' ? $::form->{filter}->{transferred_eq_ignore_empty} : '';
67
  my $sort_by = $::form->{sort_by} ? $::form->{sort_by} : 'order_date';
68
  $sort_by .=$::form->{sort_dir} ? ' DESC' : ' ASC';
69
  my $shop_orders = SL::DB::Manager::ShopOrder->get_all( %filter, sort_by => $sort_by,
70
                                                      with_objects => ['shop_order_items', 'kivi_customer', 'shop'],
71
                                                    );
72

  
73
  foreach my $shop_order(@{ $shop_orders }){
74

  
75
    my $open_invoices = SL::DB::Manager::Invoice->get_all_count(
76
      query => [customer_id => $shop_order->{kivi_customer_id},
77
              paid => {lt_sql => 'amount'},
78
      ],
79
    );
80
    $shop_order->{open_invoices} = $open_invoices;
81
  }
82
  $self->_setup_list_action_bar;
83
  $self->render('shop_order/list',
84
                title       => t8('ShopOrders'),
85
                SHOPORDERS  => $shop_orders,
86
                TOOK        => $transferred,
87
              );
88
}
89

  
90
sub action_show {
91
  my ( $self ) = @_;
92
  my $id = $::form->{id} || {};
93
  my $shop_order = SL::DB::ShopOrder->new( id => $id )->load( with => ['kivi_customer'] );
94
  die "can't find shoporder with id $id" unless $shop_order;
95

  
96
  my $proposals = $shop_order->check_for_existing_customers;
97

  
98
  $self->render('shop_order/show',
99
                title       => t8('Shoporder'),
100
                IMPORT      => $shop_order,
101
                PROPOSALS   => $proposals,
102
              );
103

  
104
}
105

  
106
sub action_delete_order {
107
  my ( $self ) = @_;
108

  
109
  $self->shop_order->obsolete(1);
110
  $self->shop_order->save;
111
  $self->redirect_to(controller => "ShopOrder", action => 'list', filter => { 'transferred:eq_ignore_empty' => 0 });
112
}
113

  
114
sub action_undelete_order {
115
  my ( $self ) = @_;
116

  
117
  $self->shop_order->obsolete(0);
118
  $self->shop_order->save;
119
  $self->redirect_to(controller => "ShopOrder", action => 'show', id => $self->shop_order->id);
120
}
121

  
122
sub action_transfer {
123
  my ( $self ) = @_;
124

  
125
  my $customer = SL::DB::Manager::Customer->find_by(id => $::form->{customer});
126
  die "Can't find customer" unless $customer;
127
  my $employee = SL::DB::Manager::Employee->current;
128
  die "Can't find employee" unless $employee;
129

  
130
  die "Can't load shop_order form form->import_id" unless $self->shop_order;
131
  my $order = $self->shop_order->convert_to_sales_order(customer => $customer, employee => $employee);
132

  
133
  if ($order->{error}){
134
    flash_later('error',@{$order->{errors}});
135
    $self->redirect_to(controller => "ShopOrder", action => 'show', id => $self->shop_order->id);
136
  }else{
137
    $order->db->with_transaction( sub {
138
      $order->calculate_prices_and_taxes;
139
      $order->save;
140

  
141
      my $snumbers = "ordernumber_" . $order->ordnumber;
142
      SL::DB::History->new(
143
                        trans_id    => $order->id,
144
                        snumbers    => $snumbers,
145
                        employee_id => SL::DB::Manager::Employee->current->id,
146
                        addition    => 'SAVED',
147
                        what_done   => 'Shopimport -> Order',
148
                      )->save();
149
      foreach my $item(@{ $order->orderitems }){
150
        $item->parse_custom_variable_values->save;
151
        $item->{custom_variables} = \@{ $item->cvars_by_config };
152
        $item->save;
153
      }
154

  
155
      $self->shop_order->transferred(1);
156
      $self->shop_order->transfer_date(DateTime->now_local);
157
      $self->shop_order->save;
158
      $self->shop_order->link_to_record($order);
159
    }) || die $order->db->error;
160
    $self->redirect_to(controller => "oe.pl", action => 'edit', type => 'sales_order', vc => 'customer', id => $order->id);
161
  }
162
}
163

  
164
sub action_mass_transfer {
165
  my ($self) = @_;
166
  my @shop_orders =  @{ $::form->{id} || [] };
167

  
168
  my $job                   = SL::DB::BackgroundJob->new(
169
    type                    => 'once',
170
    active                  => 1,
171
    package_name            => 'ShopOrderMassTransfer',
172
  )->set_data(
173
     shop_order_record_ids       => [ @shop_orders ],
174
     num_order_created           => 0,
175
     num_delivery_order_created  => 0,
176
     status                      => SL::BackgroundJob::ShopOrderMassTransfer->WAITING_FOR_EXECUTION(),
177
     conversion_errors         => [ ],
178
   )->update_next_run_at;
179

  
180
   SL::System::TaskServer->new->wake_up;
181

  
182
   my $html = $self->render('shop_order/_transfer_status', { output => 0 }, job => $job);
183

  
184
   $self->js
185
      ->html('#status_mass_transfer', $html)
186
      ->run('kivi.ShopOrder.massTransferStarted')
187
      ->render;
188
}
189

  
190
sub action_transfer_status {
191
  my ($self)  = @_;
192
  my $job     = SL::DB::BackgroundJob->new(id => $::form->{job_id})->load;
193
  my $html    = $self->render('shop_order/_transfer_status', { output => 0 }, job => $job);
194

  
195
  $self->js->html('#status_mass_transfer', $html);
196
  $self->js->run('kivi.ShopOrder.massTransferFinished') if $job->data_as_hash->{status} == SL::BackgroundJob::ShopOrderMassTransfer->DONE();
197
  $self->js->render;
198

  
199
}
200

  
201
sub action_apply_customer {
202
  my ( $self, %params ) = @_;
203
  my $shop = SL::DB::Manager::Shop->find_by( id => $self->shop_order->shop_id );
204
  my $what = $::form->{create_customer}; # new from billing, customer or delivery address
205
  my %address = ( 'name'                  => $::form->{$what.'_name'},
206
                  'department_1'          => $::form->{$what.'_company'},
207
                  'department_2'          => $::form->{$what.'_department'},
208
                  'street'                => $::form->{$what.'_street'},
209
                  'zipcode'               => $::form->{$what.'_zipcode'},
210
                  'city'                  => $::form->{$what.'_city'},
211
                  'email'                 => $::form->{$what.'_email'},
212
                  'country'               => $::form->{$what.'_country'},
213
                  'phone'                 => $::form->{$what.'_phone'},
214
                  'email'                 => $::form->{$what.'_email'},
215
                  'greeting'              => $::form->{$what.'_greeting'},
216
                  'taxincluded_checked'   => $shop->pricetype eq "brutto" ? 1 : 0,
217
                  'taxincluded'           => $shop->pricetype eq "brutto" ? 1 : 0,
218
                  'pricegroup_id'         => (split '\/',$shop->price_source)[0] eq "pricegroup" ?  (split '\/',$shop->price_source)[1] : undef,
219
                  'taxzone_id'            => $shop->taxzone_id,
220
                  'currency'              => $::instance_conf->get_currency_id,
221
                  #'payment_id'            => 7345,# TODO hardcoded
222
                );
223
  my $customer;
224
  if($::form->{cv_id}){
225
    $customer = SL::DB::Customer->new(id => $::form->{cv_id})->load;
226
    $customer->assign_attributes(%address);
227
    $customer->save;
228
  }else{
229
    $customer = SL::DB::Customer->new(%address);
230
    $customer->save;
231
  }
232
  my $snumbers = "customernumber_" . $customer->customernumber;
233
  SL::DB::History->new(
234
                    trans_id    => $customer->id,
235
                    snumbers    => $snumbers,
236
                    employee_id => SL::DB::Manager::Employee->current->id,
237
                    addition    => 'SAVED',
238
                    what_done   => 'Shopimport',
239
                  )->save();
240

  
241
  $self->redirect_to(action => 'show', id => $::form->{import_id});
242
}
243

  
244
sub setup {
245
  my ($self) = @_;
246
  $::auth->assert('shop_part_edit');
247
  $::request->layout->use_javascript("${_}.js")  for qw(kivi.ShopOrder);
248
}
249

  
250
sub check_auth {
251
  $::auth->assert('shop_part_edit');
252
}
253
#
254
# Helper
255
#
256

  
257
sub init_shop_order {
258
  my ( $self ) = @_;
259
  return SL::DB::ShopOrder->new(id => $::form->{import_id})->load if $::form->{import_id};
260
}
261

  
262
sub init_transferred {
263
  [ { title => t8("all"),             value => '' },
264
    { title => t8("transferred"),     value => 1  },
265
    { title => t8("not transferred"), value => 0  }, ]
266
}
267

  
268
sub init_shops {
269
  SL::DB::Shop->shops_dd;
270
}
271

  
272
sub _setup_list_action_bar {
273
  my ($self) = @_;
274

  
275
  for my $bar ($::request->layout->get('actionbar')) {
276
    $bar->add(
277
        action => [
278
          t8('Search'),
279
          submit    => [ '#shoporders', { action => "ShopOrder/list" } ],
280
        ],
281
         link => [
282
          t8('Shoporders'),
283
          link => [ $self->url_for(action => 'get_orders') ],
284
          tooltip => t8('New shop orders'),
285
        ],
286
        'separator',
287
        action => [
288
          t8('Execute'),
289
          call => [ 'kivi.ShopOrder.setup', id => "mass_transfer" ],
290
          tooltip => t8('Transfer all marked'),
291
        ],
292
    );
293
  }
294
}
295

  
296
1;
297

  
298
__END__
299

  
300
=encoding utf-8
301

  
302
=head1 NAME
303

  
304
SL::Controller::ShopOrder - Shoporder CRUD Controller
305

  
306
=head1 DESCRIPTION
307

  
308
Fetches the shoporders and transfers them to orders.
309

  
310
Relations for shoporders
311

  
312
=over 2
313

  
314
=item shop_order_items
315

  
316
=item shops
317

  
318
=item shop_parts
319

  
320
=back
321

  
322
=head1 URL ACTIONS
323

  
324
=over 4
325

  
326
=item C<action_get_orders>
327

  
328
Fetches the shoporders with the shopconnector class
329

  
330
=item C<action_list>
331

  
332
List the shoporders by different filters.
333
From the List you can transfer shoporders into orders in batch where it is possible or one by one.
334

  
335
=item C<action_show>
336

  
337
Shows one order. From here you can apply/change/select customer data and transfer the shoporder to an order.
338

  
339
=item C<action_delete>
340

  
341
Marks the shoporder as obsolete. It's for shoporders you don't want to transfer.
342

  
343
=item C<action_undelete>
344

  
345
Marks the shoporder obsolete = false
346

  
347
=item C<action_transfer>
348

  
349
Transfers one shoporder to an order.
350

  
351
=item C<action_apply_customer>
352

  
353
Applys a new customer from the shoporder.
354

  
355
=back
356

  
357
=head1 TASKSERVER ACTIONS
358

  
359
=over 4
360

  
361
=item C<action_mass_transfer>
362

  
363
Transfers more shoporders by backgroundjob called from the taskserver to orders.
364

  
365
=item C<action_transfer_status>
366

  
367
Shows the backgroundjobdata for the popup status window
368

  
369
=back
370

  
371
=head1 SETUP
372

  
373
=over 4
374

  
375
=item C<setup>
376

  
377
=back
378

  
379
=head1 INITS
380

  
381
=over 4
382

  
383
=item C<init_shoporder>
384

  
385
=item C<init_transfered>
386

  
387
Transferstatuses for the filter dropdown
388

  
389
=item C<init_shops>
390

  
391
Filter dropdown Shops
392

  
393
=back
394

  
395
=head1 TODO
396

  
397
Implements different payments, pricesources and pricegroups. Till now not needed.
398

  
399
=head1 BUGS
400

  
401
None yet. :)
402

  
403
=head1 AUTHOR
404

  
405
W. Hahn E<lt>wh@futureworldsearch.netE<gt>
406

  
407
=cut
SL/DB/Helper/LinkedRecords.pm
312 312
                  'SL::DB::PurchaseInvoice' => sub { $_[0]->invnumber },
313 313
                  'SL::DB::RequirementSpec' => sub { $_[0]->id },
314 314
                  'SL::DB::Letter'          => sub { $_[0]->letternumber },
315
                  'SL::DB::ShopOrder'       => sub { $_[0]->shop_ordernumber },
315 316
                  UNKNOWN                   => '9999999999999999',
316 317
                );
317 318
  my $number_xtor = sub {
......
341 342
              'SL::DB::PurchaseInvoice' => 150,
342 343
              'SL::DB::PurchaseInvoice' => 150,
343 344
              'SL::DB::Letter'          => 200,
345
              'SL::DB::ShopOrder'       => 250,
344 346
              UNKNOWN                   => 999,
345 347
            );
346 348
  my $score_xtor = sub {
js/kivi.ShopOrder.js
1
namespace('kivi.ShopOrder', function(ns) {
2
  ns.massTransferInitialize = function() {
3
    kivi.popup_dialog({
4
      id: 'status_mass_transfer',
5
      dialog: {
6
        title: kivi.t8('Status Shoptransfer'),
7
      }
8
    });
9
  };
10

  
11
  ns.massTransferStarted = function() {
12
    $('#status_mass_transfer').data('timerId', setInterval(function() {
13
      $.get("controller.pl", {
14
        action: 'ShopOrder/transfer_status',
15
        job_id: $('#smt_job_id').val()
16
      }, kivi.eval_json_result);
17
    }, 5000));
18
  };
19

  
20
  ns.massTransferFinished = function() {
21
    clearInterval($('#status_mass_transfer').data('timerId'));
22
    $('.ui-dialog-titlebar button.ui-dialog-titlebar-close').prop('disabled', '')
23
  };
24

  
25
  ns.processClose = function() {
26
    $('#status_mass_transfer').dialog('close');
27
    window.location.href = 'controller.pl?filter.obsolete=0&filter.transferred=0&action=ShopOrder%2flist&db=shop_orders&sort_by=shop_ordernumber';
28
  };
29

  
30
  ns.setup = function() {
31
    kivi.ShopOrder.massTransferInitialize();
32
    kivi.submit_ajax_form('controller.pl?action=ShopOrder/mass_transfer','[name=shop_orders_list]');
33
  };
34

  
35
});
templates/webpages/shop_order/_filter.html
1
[%- USE T8 %]
2
[%- USE L %]
3
[%- USE LxERP %]
4
[%- USE HTML %]
5
 <form method="post" action="controller.pl" name="shop_orders" id="shoporders">
6
 <table id='filter_table'>
7

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

  
13
    <tr>
14
     <th align="right">[% 'Status' | $T8 %]</th>
15
     <td>[% L.select_tag('filter.transferred:eq_ignore_empty', SELF.transferred, value_key = 'value', title_key = 'title', default=0) %]</td>
16
    </tr>
17

  
18

  
19
    <tr>
20
     <th align="right">[% 'from' | $T8 %]</th>
21
     <td>[% L.date_tag('filter.order_date:date::ge', FORM.filter.order_date_date__ge) %]</td>
22
    </tr>
23

  
24
    <tr>
25
     <th align="right">[% 'to' | $T8 %]</th>
26
     <td>[% L.date_tag('filter.order_date:date::le', FORM.filter.order_date_date__le) %]</td>
27
    </tr>
28

  
29
    <tr>
30
      <th align="right">[% 'Obsolete' | $T8 %]</th>
31
      <td>[% L.yes_no_tag('filter.obsolete', FORM.filter.obsolete, default='0', with_empty=1, empty_title='---') %]</td>
32
    </tr>
33

  
34
 </table>
35

  
36

  
37
<a href='#' onClick='javascript:$("#filter_table input").val("");$("#filter_table input[type=checkbox]").prop("checked", 0);'>[% 'Reset' | $T8 %]</a>
38
<br>
templates/webpages/shop_order/_transfer_status.html
1
[%- USE LxERP -%][%- USE L -%][%- USE HTML -%]
2
[%- USE Dumper -%]
3
[% SET data = job.data_as_hash %]
4

  
5

  
6
<h2>[% LxERP.t8("Watch status") %]</h2>
7

  
8
[% L.hidden_tag('', job.id, id="smt_job_id") %]
9

  
10
JOBID: [% job.id %] <p>
11
 [% LxERP.t8("This status output will be refreshed every five seconds.") %]
12
</p>
13
<p>
14
</p>
15
<p>
16
 [% L.link("#", LxERP.t8("Close window"), onclick="kivi.ShopOrder.processClose();") %]
17
 <table>
18
  <tr>
19
   <th valign="top" align="left">[% LxERP.t8("Current status:") %]</th>
20
   <td valign="top">
21
    [% IF !data.status %]
22
     [% LxERP.t8("waiting for job to be started") %]
23
    [% ELSIF data.status == 1 %]
24
     [% LxERP.t8("Converting to deliveryorder") %]
25
     [% ELSE %]
26
     [% LxERP.t8("Done.") %]
27
    [% END %]
28
   </td>
29
  </tr>
30
  <tr>
31
   <th valign="top" align="left">[% LxERP.t8("Number of orders created:") %]</th>
32
   <td valign="top">[% IF data.status > 0 %][% HTML.escape(data.num_order_created) %] / [% HTML.escape(data.shop_order_record_ids.size) %][% ELSE %]–[% END %]</td>
33
  </tr>
34

  
35

  
36
  <tr>
37
   <th valign="top" align="left">[% LxERP.t8("Errors during conversion:") %]</th>
38
   <td valign="top">
39
[% IF !data.status %]
40
41
[% ELSIF !data.conversion_errors.size %]
42
 [% LxERP.t8("No errors have occurred.") %]
43
[% ELSE %]
44
    <table>
45
     <tr class="listheader">
46
      <th>[% LxERP.t8("Shoporder") %]</th>
47
      <th>[% LxERP.t8("Error") %]</th>
48
     </tr>
49

  
50
 [% FOREACH error = data.conversion_errors %]
51
     <tr>
52
      <td valign="top">[% HTML.escape(error.number) %]</td>
53
      <td valign="top">[% FOREACH message = error.message %][% HTML.escape(message) %]<br>[% END %]</td>
54
     </tr>
55
 [% END %]
56
    </table>
57
[% END %]
58
   </td>
59
  </tr>
60
 </table>
61
</p>
templates/webpages/shop_order/list.html
1
[%- USE HTML -%][%- USE LxERP -%][%- USE L -%][%- USE T8 -%]
2
[% USE Dumper %]
3

  
4
[% L.stylesheet_tag('webshop') %]
5
[%- INCLUDE 'common/flash.html' %]
6
<h1>[% title %]<span style="float:right;">[% 'Number data sets' | $T8 %]: [% SHOPORDERS.size %]</span></h1>
7
[%- PROCESS 'shop_order/_filter.html' filter=SELF.models.filtered.laundered %]
8

  
9
<hr>
10

  
11
 <table id="shoplist" width="100%">
12
  <thead>
13
   <tr class="listheading">
14
    <th>[% 'Shop' | $T8 %]</th>
15
    <th>[% IF FORM.sort_by == 'order_date' %]
16
      <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 %]&filter.order_date:date::ge=[% FORM.filter.order_date_date__ge %]&filter.order_date:date::le=[% FORM.filter.order_date_date__le %]&filter.obsolete=[% FORM.filter.obsolete %]" class="sort_link">
17
        [% '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>
18
    [% ELSE %]
19
      <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&filter.order_date:date::ge=[% FORM.filter.order_date_date__ge %]&filter.order_date:date::le=[% FORM.filter.order_date_date__le %]&filter.obsolete=[% FORM.filter.obsolete %]" class="sort_link">
20
        [% 'Shop orderdate' | $T8 %]</a>
21
    [% END %]
22
    <br>
23
    [% IF FORM.sort_by == 'itime' %]
24
      <a href ="controller.pl?action=ShopOrder/list&filter.transferred:eq_ignore_empty=[% FORM.filter.transferred_eq_ignore_empty %]&sort_by=itime&sort_dir=[% 1 - FORM.sort_dir %]&filter.order_date:date::ge=[% FORM.filter.order_date_date__ge %]&filter.order_date:date::le=[% FORM.filter.order_date_date__le %]&filter.obsolete=[% FORM.filter.obsolete %]" class="sort_link">
25
        [% 'Importdate' | $T8 %][% IF FORM.sort_dir == 0 %]<img border="0" src="image/down.png">[% ELSE %]<img border="0" src="image/up.png">[% END %]</a>
26
    [% ELSE %]
27
      <a href ="controller.pl?action=ShopOrder/list&filter.transferred:eq_ignore_empty=[% FORM.filter.transferred_eq_ignore_empty %]&sort_by=itime&sort_dir=0&filter.order_date:date::ge=[% FORM.filter.order_date_date__ge %]&filter.order_date:date::le=[% FORM.filter.order_date_date__le %]&filter.obsolete=[% FORM.filter.obsolete %]" class="sort_link">
28
        [% 'Importdate' | $T8 %]</a>
29
    [% END %]
30
    </th>
31
    <th>[% IF FORM.sort_by == 'shop_ordernumber' %]
32
      <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 %]&filter.order_date:date::ge=[% FORM.filter.order_date_date__ge %]&filter.order_date:date::le=[% FORM.filter.order_date_date__le %]&filter.obsolete=[% FORM.filter.obsolete %]" class="sort_link">
33
        [% '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>
34
    [% ELSE %]
35
      <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&filter.order_date:date::ge=[% FORM.filter.order_date_date__ge %]&filter.order_date:date::le=[% FORM.filter.order_date_date__le %]&filter.obsolete=[% FORM.filter.obsolete %]" class="sort_link">
36
        [% 'Shop ordernumber' | $T8 %]</a>
37
    [% END %]
38
    </th>
39
    <th>[% IF FORM.sort_by == 'shop_customer_number' %]
40
      <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 %]&filter.order_date:date::ge=[% FORM.filter.order_date_date__ge %]&filter.order_date:date::le=[% FORM.filter.order_date_date__le %]&filter.obsolete=[% FORM.filter.obsolete %]" class="sort_link">
41
        [% '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>
42
    [% ELSE %]
43
      <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&filter.order_date:date::ge=[% FORM.filter.order_date_date__ge %]&filter.order_date:date::le=[% FORM.filter.order_date_date__le %]&filter.obsolete=[% FORM.filter.obsolete %]" class="sort_link">
44
        [% 'Shop customernumber' | $T8 %]</a>
45
    [% END %]
46
    </th>
47
    <th>[% 'Shop Customer Address' | $T8 %]<br>
48
    [% IF FORM.sort_by == 'customer_lastname' %]
49
      <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 %]&filter.order_date:date::ge=[% FORM.filter.order_date_date__ge %]&filter.order_date:date::le=[% FORM.filter.order_date_date__le %]&filter.obsolete=[% FORM.filter.obsolete %]" class="sort_link">
50
        [% 'Name' | $T8 %][% IF FORM.sort_dir == 0 %]<img border="0" src="image/down.png">[% ELSE %]<img border="0" src="image/up.png">[% END %]</a>|
51
    [% ELSE %]
52
      <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&filter.order_date:date::ge=[% FORM.filter.order_date_date__ge %]&filter.order_date:date::le=[% FORM.filter.order_date_date__le %]&filter.obsolete=[% FORM.filter.obsolete %]" class="sort_link">
53
        [% 'Name' | $T8 %]</a>|
54
    [% END %]
55
    [% IF FORM.sort_by == 'customer_zipcode' %]
56
      <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 %]&filter.order_date:date::ge=[% FORM.filter.order_date_date__ge %]&filter.order_date:date::le=[% FORM.filter.order_date_date__le %]&filter.obsolete=[% FORM.filter.obsolete %]" class="sort_link">
57
        [% 'Zip' | $T8 %][% IF FORM.sort_dir == 0 %]<img border="0" src="image/down.png">[% ELSE %]<img border="0" src="image/up.png">[% END %]</a>|
58
    [% ELSE %]
59
      <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&filter.order_date:date::ge=[% FORM.filter.order_date_date__ge %]&filter.order_date:date::le=[% FORM.filter.order_date_date__le %]&filter.obsolete=[% FORM.filter.obsolete %]" class="sort_link">
60
        [% 'Zip' | $T8 %]</a>|
61
    [% END %]
62
    [% IF FORM.sort_by == 'customer_country' %]
63
      <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 %]&filter.order_date:date::ge=[% FORM.filter.order_date_date__ge %]&filter.order_date:date::le=[% FORM.filter.order_date_date__le %]&filter.obsolete=[% FORM.filter.obsolete %]" class="sort_link">
64
        [% 'Country' | $T8 %][% IF FORM.sort_dir == 0 %]<img border="0" src="image/down.png">[% ELSE %]<img border="0" src="image/up.png">[% END %]</a>
65
    [% ELSE %]
66
      <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&filter.order_date:date::ge=[% FORM.filter.order_date_date__ge %]&filter.order_date:date::le=[% FORM.filter.order_date_date__le %]&filter.obsolete=[% FORM.filter.obsolete %]" class="sort_link">
67
        [% 'Country' | $T8 %]</a>
68
    [% END %]
69
      </th>
70
    <th>[% 'Shop Billing Address' | $T8 %]</br>
71
    [% IF FORM.sort_by == 'billing_lastname' %]
72
      <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 %]&filter.order_date:date::ge=[% FORM.filter.order_date_date__ge %]&filter.order_date:date::le=[% FORM.filter.order_date_date__le %]&filter.obsolete=[% FORM.filter.obsolete %]" class="sort_link">
73
        [% 'Name' | $T8 %][% IF FORM.sort_dir == 0 %]<img border="0" src="image/down.png">[% ELSE %]<img border="0" src="image/up.png">[% END %]</a>|
74
    [% ELSE %]
75
      <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&filter.order_date:date::ge=[% FORM.filter.order_date_date__ge %]&filter.order_date:date::le=[% FORM.filter.order_date_date__le %]&filter.obsolete=[% FORM.filter.obsolete %]" class="sort_link">
76
        [% 'Name' | $T8 %]</a>|
77
    [% END %]
78
    [% IF FORM.sort_by == 'billing_zipcode' %]
79
      <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 %]&filter.order_date:date::ge=[% FORM.filter.order_date_date__ge %]&filter.order_date:date::le=[% FORM.filter.order_date_date__le %]&filter.obsolete=[% FORM.filter.obsolete %]" class="sort_link">
80
        [% 'Zip' | $T8 %][% IF FORM.sort_dir == 0 %]<img border="0" src="image/down.png">[% ELSE %]<img border="0" src="image/up.png">[% END %]</a>|
81
    [% ELSE %]
82
      <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&filter.order_date:date::ge=[% FORM.filter.order_date_date__ge %]&filter.order_date:date::le=[% FORM.filter.order_date_date__le %]&filter.obsolete=[% FORM.filter.obsolete %]" class="sort_link">
83
        [% 'Zip' | $T8 %]</a>|
84
    [% END %]
85
    [% IF FORM.sort_by == 'billing_country' %]
86
      <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 %]&filter.order_date:date::ge=[% FORM.filter.order_date_date__ge %]&filter.order_date:date::le=[% FORM.filter.order_date_date__le %]&filter.obsolete=[% FORM.filter.obsolete %]" class="sort_link">
87
        [% 'Country' | $T8 %][% IF FORM.sort_dir == 0 %]<img border="0" src="image/down.png">[% ELSE %]<img border="0" src="image/up.png">[% END %]</a>
88
    [% ELSE %]
89
      <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&filter.order_date:date::ge=[% FORM.filter.order_date_date__ge %]&filter.order_date:date::le=[% FORM.filter.order_date_date__le %]&filter.obsolete=[% FORM.filter.obsolete %]" class="sort_link">
90
        [% 'Country' | $T8 %]</a>
91
    [% END %]
92
      </th>
93
    <th>[% 'Shop Delivery Address' | $T8 %]</br>
94
    [% IF FORM.sort_by == 'delivery_lastname' %]
95
      <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 %]&filter.order_date:date::ge=[% FORM.filter.order_date_date__ge %]&filter.order_date:date::le=[% FORM.filter.order_date_date__le %]&filter.obsolete=[% FORM.filter.obsolete %]" class="sort_link">
96
        [% 'Name' | $T8 %][% IF FORM.sort_dir == 0 %]<img border="0" src="image/down.png">[% ELSE %]<img border="0" src="image/up.png">[% END %]</a>|
97
    [% ELSE %]
98
      <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&filter.order_date:date::ge=[% FORM.filter.order_date_date__ge %]&filter.order_date:date::le=[% FORM.filter.order_date_date__le %]&filter.obsolete=[% FORM.filter.obsolete %]" class="sort_link">
99
        [% 'Name' | $T8 %]</a>|
100
    [% END %]
101
    [% IF FORM.sort_by == 'delivery_zipcode' %]
102
      <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 %]&filter.order_date:date::ge=[% FORM.filter.order_date_date__ge %]&filter.order_date:date::le=[% FORM.filter.order_date_date__le %]&filter.obsolete=[% FORM.filter.obsolete %]" class="sort_link">
103
        [% 'Zip' | $T8 %][% IF FORM.sort_dir == 0 %]<img border="0" src="image/down.png">[% ELSE %]<img border="0" src="image/up.png">[% END %]</a>|
104
    [% ELSE %]
105
      <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&filter.order_date:date::ge=[% FORM.filter.order_date_date__ge %]&filter.order_date:date::le=[% FORM.filter.order_date_date__le %]&filter.obsolete=[% FORM.filter.obsolete %]" class="sort_link">
106
        [% 'Zip' | $T8 %]</a>|
107
    [% END %]
108
    [% IF FORM.sort_by == 'delivery_country' %]
109
      <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 %]&filter.order_date:date::ge=[% FORM.filter.order_date_date__ge %]&filter.order_date:date::le=[% FORM.filter.order_date_date__le %]&filter.obsolete=[% FORM.filter.obsolete %]" class="sort_link">
110
        [% 'Country' | $T8 %][% IF FORM.sort_dir == 0 %]<img border="0" src="image/down.png">[% ELSE %]<img border="0" src="image/up.png">[% END %]</a>
111
    [% ELSE %]
112
      <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&filter.order_date:date::ge=[% FORM.filter.order_date_date__ge %]&filter.order_date:date::le=[% FORM.filter.order_date_date__le %]&filter.obsolete=[% FORM.filter.obsolete %]" class="sort_link">
113
        [% 'Country' | $T8 %]</a>
114
    [% END %]
115
      </th>
116
    <th>[% IF FORM.sort_by == 'shop_customer_comment' %]
117
      <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 %]&filter.order_date:date::ge=[% FORM.filter.order_date_date__ge %]&filter.order_date:date::le=[% FORM.filter.order_date_date__le %]&filter.obsolete=[% FORM.filter.obsolete %]" class="sort_link">
118
        [% 'Notes' | $T8 %][% IF FORM.sort_dir == 0 %]<img border="0" src="image/down.png">[% ELSE %]<img border="0" src="image/up.png">[% END %]</a>
119
    [% ELSE %]
120
      <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&filter.order_date:date::ge=[% FORM.filter.order_date_date__ge %]&filter.order_date:date::le=[% FORM.filter.order_date_date__le %]&filter.obsolete=[% FORM.filter.obsolete %]" class="sort_link">
121
        [% 'Notes' | $T8 %]</a>
122
    [% END %]
123
    </th>
124
    <th>
125
      [% IF FORM.sort_by == 'positions' %]
126
      <a href ="controller.pl?action=ShopOrder/list&filter.transferred:eq_ignore_empty=[% FORM.filter.transferred_eq_ignore_empty %]&sort_by=positions&sort_dir=[% 1 - FORM.sort_dir %]&filter.order_date:date::ge=[% FORM.filter.order_date_date__ge %]&filter.order_date:date::le=[% FORM.filter.order_date_date__le %]&filter.obsolete=[% FORM.filter.obsolete %]" class="sort_link">
127
        [% 'Positions' | $T8 %][% IF FORM.sort_dir == 0 %]<img border="0" src="image/down.png">[% ELSE %]<img border="0" src="image/up.png">[% END %]</a><br>
128
      [% ELSE %]
129
      <a href ="controller.pl?action=ShopOrder/list&filter.transferred:eq_ignore_empty=[% FORM.filter.transferred_eq_ignore_empty %]&sort_by=positions&sort_dir=0&filter.order_date:date::ge=[% FORM.filter.order_date_date__ge %]&filter.order_date:date::le=[% FORM.filter.order_date_date__le %]&filter.obsolete=[% FORM.filter.obsolete %]" class="sort_link"> [% 'Positions' | $T8 %]</a><br>
130
      [% END %]
131
      [% IF FORM.sort_by == 'amount' %]
132
      <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 %]&filter.order_date:date::ge=[% FORM.filter.order_date_date__ge %]&filter.order_date:date::le=[% FORM.filter.order_date_date__le %]&filter.obsolete=[% FORM.filter.obsolete %]" class="sort_link">
133
        [% 'Amount' | $T8 %][% IF FORM.sort_dir == 0 %]<img border="0" src="image/down.png">[% ELSE %]<img border="0" src="image/up.png">[% END %]</a><br>
134
      [% ELSE %]
135
      <a href ="controller.pl?action=ShopOrder/list&filter.transferred:eq_ignore_empty=[% FORM.filter.transferred_eq_ignore_empty %]&sort_by=amount&sort_dir=0&filter.order_date:date::ge=[% FORM.filter.order_date_date__ge %]&filter.order_date:date::le=[% FORM.filter.order_date_date__le %]&filter.obsolete=[% FORM.filter.obsolete %]" class="sort_link"> [% 'Amount' | $T8 %]</a><br>
136
      [% END %]
137
      [% IF FORM.sort_by == 'shipping_costs' %]
138
      <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 %]&filter.order_date:date::ge=[% FORM.filter.order_date_date__ge %]&filter.order_date:date::le=[% FORM.filter.order_date_date__le %]&filter.obsolete=[% FORM.filter.obsolete %]" class="sort_link">
139
        [% 'Shippingcosts' | $T8 %][% IF FORM.sort_dir == 0 %]<img border="0" src="image/down.png">[% ELSE %]<img border="0" src="image/up.png">[% END %]</a>
140
      [% ELSE %]
141
      <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&filter.order_date:date::ge=[% FORM.filter.order_date_date__ge %]&filter.order_date:date::le=[% FORM.filter.order_date_date__le %]&filter.obsolete=[% FORM.filter.obsolete %]" class="sort_link"> [% 'Shippingcosts' | $T8 %]</a>
142
      [% END %]
143
    </th>
144
    <th>[% 'Action' | $T8 %]<br>[% L.checkbox_tag('check_all') %]</th>
145
   </tr>
146
  </thead>
147
 </form>
148
 <form method="post" action="controller.pl" name="shop_orders_list" id="shoporderslist">
149
  [% FOREACH shop_order = SHOPORDERS %]
150
  [% # Dumper.dump_html(shop_order) %]
151
    [% IF shop_order.kivi_customer.id && shop_order.kivi_customer.order_lock == 0 && shop_order.open_invoices == 0 %] [% SET transferable = 1 %] [% SET transferable_class = 'class="shop_transferable"' %] [% ELSE %] [% SET transferable = 0 %] [% SET transferable_class = '' %][% END %]
152
  <tr class="listrow">
153
    <td>[% HTML.escape(shop_order.shop.description) %]</td>
154
    <td>[% shop_order.order_date.to_kivitendo('precision' => 'minute') %]<br>[% shop_order.itime.to_kivitendo('precision' => 'minute') %]</td>
155
    <td>[% HTML.escape(shop_order.shop_ordernumber) %]</td>
156
    <td>[% HTML.escape(shop_order.shop_customer_number) %]</td>
157
    <td>[% IF shop_order.customer_company %]<b>[% HTML.escape(shop_order.customer_company) %]</b><br>[% END %]
158
      <b>[% HTML.escape(shop_order.customer_lastname) %],&nbsp;[% HTML.escape(shop_order.customer_firstname) %]</b>
159
      <br>[% HTML.escape(shop_order.customer_street) %]
160
      <br>[% HTML.escape(shop_order.customer_zipcode) %]&nbsp;[% HTML.escape(shop_order.customer_city) %]
161
      <br>[% HTML.escape(shop_order.customer_country) %] </td>
162
    <td [% transferable_class %]>[% IF shop_order.customer_company %]<b>[% HTML.escape(shop_order.customer_company) %]</b><br>[% END %]
163
      <b>[% HTML.escape(shop_order.billing_lastname) %],&nbsp;[% HTML.escape(shop_order.billing_firstname) %]</b>
164
      <br>[% HTML.escape(shop_order.billing_street) %]
165
      <br>[% HTML.escape(shop_order.billing_zipcode) %]&nbsp;[% HTML.escape(shop_order.billing_city) %]
166
      <br>[% HTML.escape(shop_order.billing_country) %]
167
      <br>[% IF shop_order.open_invoices > 0 || shop_order.customer.order_lock == 1 %][% SET alertclass = 'class="shop_alert"' %][% ELSE %][% SET alertclass = '' %][% END %]<span [% alertclass %]>&nbsp;&nbsp;[% 'Customernumber' | $T8 %] [% HTML.escape(shop_order.kivi_customer.customernumber) %] -- [% 'Invoices' | $T8 %] [% shop_order.open_invoices %]&nbsp;&nbsp;</span></td>
168
    [% 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 = 'class="shop_delivery"' %] [% ELSE %] [% SET deliveryclass = '' %] [% END %]
169
    <td [% deliveryclass %]>[% IF shop_order.customer_company %]<b>[% HTML.escape(shop_order.customer_company) %]</b><br>[% END %]
170
      <b>[% HTML.escape(shop_order.delivery_lastname) %],&nbsp;[% HTML.escape(shop_order.delivery_firstname) %]</b>
171
      <br>[% HTML.escape(shop_order.delivery_street) %]
172
      <br>[% HTML.escape(shop_order.delivery_zipcode) %]&nbsp;[% HTML.escape(shop_order.delivery_city) %]
173
      <br>[% HTML.escape(shop_order.delivery_country) %] </td>
174
    <td>[% HTML.escape(shop_order.shop_customer_comment) %]</td>
175
    <td><span class="tooltipster-html" title="[% FOREACH item = shop_order.shop_order_items %] [% LxERP.format_amount(item.quantity,0) %] x [% item.partnumber %] [% item.description %] <br> [% END %]">[% shop_order.positions %]<br>[% shop_order.amount_as_number %]<br>[% shop_order.shipping_costs_as_number %]</td><span>
176
    <td valign="middle">[% 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>
177
        [% ELSE %]
178
          [% IF transferable == 1 && shop_order.obsolete == 0 %]
179
            [% L.checkbox_tag('id[]', checked = '1',  value=shop_order.id) %]<br>
180
          [% END %]
181
          [% IF shop_order.obsolete == 0 %]<a href="controller.pl?id=[% shop_order.id %]&action=ShopOrder/show">[% 'Create order' | $T8 %]</a></br></br>
182
          <a href="controller.pl?import_id=[% shop_order.id %]&action=ShopOrder/delete_order">[% 'Delete shoporder' | $T8 %]</a>
183
          [% ELSE %]
184
          [% 'Obsolete' | $T8 %]<br><br>
185
            <a href="controller.pl?id=[% shop_order.id %]&action=ShopOrder/show">[% 'Show order' | $T8 %]
186
          [% END %]
187
    </td>
188
        [% END %]
189
  </tr>
190
  [% END %]
191
 </table>
192
 <hr>
193
  <div id="status_mass_transfer" style="display: none;">
194
    [%- INCLUDE 'shop_order/_transfer_status.html' %]
195
  </div>
196
 </form>
197
<script type="text/javascript">
198
<!--
199

  
200
$(function() {
201
  $('#check_all').checkall('INPUT[name^="id"]');
202
});
203
-->
204
</script>
templates/webpages/shop_order/show.html
1
[%- USE HTML -%][%- USE LxERP -%][%- USE L -%][%- USE T8 -%]
2
[% L.stylesheet_tag('webshop') %]
3
[%- INCLUDE 'common/flash.html' %]
4
<h1>[% title %]</h1>
5

  
6
  <div class="shop_table shop_main">
7
    <div class="shop_table-row">
8
      <div class="shop_table-cell">
9
      <form method="post" action="controller.pl" id="customer">[% L.hidden_tag('create_customer','customer') %][% L.hidden_tag('import_id', IMPORT.id) %]
10
        <div class="shop_table shop_table_address">
11
          <div class="shop_table-row listheading">
12
            <div class="shop_table-cell">[% 'Shop Customer Address' | $T8 %]</div>
13
            <div class="shop_table-cell"></div>
14
          </div>
15
          <div class="shop_table-row"><div class="shop_table-cell listheading">[% 'Greeting' | $T8 %]</div><div class="shop_table-cell">[% HTML.escape(IMPORT.customer_greeting) %]</div></div>
16
          <div class="shop_table-row"><div class="shop_table-cell listheading">[% 'Firstname' | $T8 %]</div><div class="shop_table-cell">[% HTML.escape(IMPORT.customer_firstname) %]</div></div>
17
          <div class="shop_table-row"><div class="shop_table-cell listheading">[% 'Lastname' | $T8 %]</div><div class="shop_table-cell">[% HTML.escape(IMPORT.customer_lastname) %]</div></div>
18
          <div class="shop_table-row"><div class="shop_table-cell listheading">[% 'Company' | $T8 %]</div><div class="shop_table-cell">[% HTML.escape(IMPORT.customer_company) %]</div></div>
19
          <div class="shop_table-row"><div class="shop_table-cell listheading">[% 'Department' | $T8 %]</div><div class="shop_table-cell">[% HTML.escape(IMPORT.customer_department) %]</div></div>
20
            [% SET customer = IMPORT.customer_firstname _ ' ' _ IMPORT.customer_lastname %]
21
          <hr>
22
          <div class="shop_table-row"><div class="shop_table-cell listheading">[% 'Greeting' | $T8 %]</div><div class="shop_table-cell">[% L.input_tag('customer_greeting', IMPORT.customer_greeting) %]</div></div>
23
          <div class="shop_table-row"><div class="shop_table-cell listheading">[% 'Customer' | $T8 %]</div><div class="shop_table-cell">[% L.input_tag('customer_name', customer) %]</div></div>
24
          <div class="shop_table-row"><div class="shop_table-cell listheading">[% 'Name 2' | $T8 %]</div><div class="shop_table-cell">[% L.input_tag('customer_company', IMPORT.customer_company) %]</div></div>
25
          <div class="shop_table-row"><div class="shop_table-cell listheading">[% 'Name 3' | $T8 %]</div><div class="shop_table-cell">[% L.input_tag('customer_department', IMPORT.customer_department) %]</div></div>
26
          <div class="shop_table-row"><div class="shop_table-cell listheading">[% 'Street' | $T8 %]</div><div class="shop_table-cell">[% L.input_tag('customer_street', IMPORT.customer_street) %]</div></div>
27
          <div class="shop_table-row"><div class="shop_table-cell listheading">[% 'Zipcode' | $T8 %]</div><div class="shop_table-cell">[% L.input_tag('customer_zipcode', IMPORT.customer_zipcode) %]</div></div>
28
          <div class="shop_table-row"><div class="shop_table-cell listheading">[% 'City' | $T8 %]</div><div class="shop_table-cell">[% L.input_tag('customer_city', IMPORT.customer_city) %]</div></div>
29
          <div class="shop_table-row"><div class="shop_table-cell listheading">[% 'Country' | $T8 %]</div><div class="shop_table-cell">[% L.input_tag('customer_country', IMPORT.customer_country) %]</div></div>
30
          <div class="shop_table-row"><div class="shop_table-cell listheading">[% 'Phone' | $T8 %]</div><div class="shop_table-cell">[% L.input_tag('customer_phone', IMPORT.customer_phone) %]</div></div>
31
          <div class="shop_table-row"><div class="shop_table-cell listheading">[% 'Email' | $T8 %]</div><div class="shop_table-cell">[% L.input_tag('customer_email', IMPORT.customer_email) %]</div></div>
32
          [% IF C_ADDRESS %]
33
          <div class="shop_table-row"><div class="shop_table-cell listheading">[% 'Customernumber' | $T8 %]</div><div class="shop_table-cell">[% C_ADDRESS.customernumber %]</div></div>
34
          [% ELSE %]
35
          <div>[% L.ajax_submit_tag("controller.pl?action=ShopOrder/apply_customer",  "#customer", LxERP.t8("Apply customer")) %]</div>
36
          [% END %]
37
        </div>
38
      </form>
39
      </div>
40
      <div class="shop_table-cell">
41
      <form method="post" action="controller.pl" id="billing">[% L.hidden_tag('create_customer','billing') %][% L.hidden_tag('import_id', IMPORT.id) %]
42
        <div class="shop_table shop_table_address">
43
          <div class="shop_table-row listheading">
44
            <div class="shop_table-cell">[% 'Shop Billing Address' | $T8 %]</div>
45
            <div class="shop_table-cell"></div>
46
          </div>
47
          <div class="shop_table-row"><div class="shop_table-cell listheading">[% 'Greeting' | $T8 %]</div><div class="shop_table-cell">[% HTML.escape(IMPORT.billing_greeting) %]</div></div>
48
          <div class="shop_table-row"><div class="shop_table-cell listheading">[% 'Firstname' | $T8 %]</div><div class="shop_table-cell">[% HTML.escape(IMPORT.billing_firstname) %]</div></div>
49
          <div class="shop_table-row"><div class="shop_table-cell listheading">[% 'Lastname' | $T8 %]</div><div class="shop_table-cell">[% HTML.escape(IMPORT.billing_lastname) %]</div></div>
50
          <div class="shop_table-row"><div class="shop_table-cell listheading">[% 'Company' | $T8 %]</div><div class="shop_table-cell">[% HTML.escape(IMPORT.billing_company) %]</div></div>
51
          <div class="shop_table-row"><div class="shop_table-cell listheading">[% 'Department' | $T8 %]</div><div class="shop_table-cell">[% HTML.escape(IMPORT.billing_department) %]</div></div>
52
            [% SET billing = IMPORT.billing_firstname _ ' ' _ IMPORT.billing_lastname %]
53
          <hr>
54
          <div class="shop_table-row"><div class="shop_table-cell listheading">[% 'Greeting' | $T8 %]</div><div class="shop_table-cell">[% L.input_tag('billing_greeting', IMPORT.billing_greeting) %]</div></div>
55
          <div class="shop_table-row"><div class="shop_table-cell listheading">[% 'Customer' | $T8 %]</div><div class="shop_table-cell">[% L.input_tag('billing_name', billing) %]</div></div>
56
          <div class="shop_table-row"><div class="shop_table-cell listheading">[% 'Name 2' | $T8 %]</div><div class="shop_table-cell">[% L.input_tag('billing_company', IMPORT.billing_company) %]</div></div>
57
          <div class="shop_table-row"><div class="shop_table-cell listheading">[% 'Name 3' | $T8 %]</div><div class="shop_table-cell">[% L.input_tag('billing_department', IMPORT.billing_department) %]</div></div>
58
          <div class="shop_table-row"><div class="shop_table-cell listheading">[% 'Street' | $T8 %]</div><div class="shop_table-cell">[% L.input_tag('billing_street', IMPORT.billing_street) %]</div></div>
59
          <div class="shop_table-row"><div class="shop_table-cell listheading">[% 'Zipcode' | $T8 %]</div><div class="shop_table-cell">[% L.input_tag('billing_zipcode', IMPORT.billing_zipcode) %]</div></div>
60
          <div class="shop_table-row"><div class="shop_table-cell listheading">[% 'City' | $T8 %]</div><div class="shop_table-cell">[% L.input_tag('billing_city', IMPORT.billing_city) %]</div></div>
61
          <div class="shop_table-row"><div class="shop_table-cell listheading">[% 'Country' | $T8 %]</div><div class="shop_table-cell">[% L.input_tag('billing_country', IMPORT.billing_country) %]</div></div>
62
          <div class="shop_table-row"><div class="shop_table-cell listheading">[% 'Phone' | $T8 %]</div><div class="shop_table-cell">[% L.input_tag('billing_phone', IMPORT.billing_phone) %]</div></div>
63
          <div class="shop_table-row"><div class="shop_table-cell listheading">[% 'Email' | $T8 %]</div><div class="shop_table-cell">[% L.input_tag('billing_email', IMPORT.billing_email) %]</div></div>
64
          [% IF B_ADDRESS %]
65
          <div class="shop_table-row"><div class="shop_table-cell listheading">[% 'Customernumber' | $T8 %]</div><div class="shop_table-cell">[% B_ADDRESS.customernumber %]</div></div>
66
          [% ELSE %]
67
          <div>[% L.ajax_submit_tag("controller.pl?action=ShopOrder/apply_customer",  "#billing", LxERP.t8("Apply customer")) %]</div>
68
          [% END %]
69
        </div>
70
      </form>
71
      </div>
72
      <div class="shop_table-cell">
73
      <form method="post" action="controller.pl" id="delivery">[% L.hidden_tag('create_customer','delivery') %][% L.hidden_tag('import_id', IMPORT.id) %]
74
        <div class="shop_table shop_table_address">
75
          <div class="shop_table-row listheading">
76
            <div class="shop_table-cell">[% 'Shop Delivery Address' | $T8 %]</div>
77
            <div class="shop_table-cell"></div>
78
          </div>
79
          <div class="shop_table-row"><div class="shop_table-cell listheading">[% 'Greeting' | $T8 %]</div><div class="shop_table-cell">[% HTML.escape(IMPORT.delivery_greeting) %]</div></div>
80
          <div class="shop_table-row"><div class="shop_table-cell listheading">[% 'Firstname' | $T8 %]</div><div class="shop_table-cell">[% HTML.escape(IMPORT.delivery_firstname) %]</div></div>
81
          <div class="shop_table-row"><div class="shop_table-cell listheading">[% 'Lastname' | $T8 %]</div><div class="shop_table-cell">[% HTML.escape(IMPORT.delivery_lastname) %]</div></div>
82
          <div class="shop_table-row"><div class="shop_table-cell listheading">[% 'Company' | $T8 %]</div><div class="shop_table-cell">[% HTML.escape(IMPORT.delivery_company) %]</div></div>
83
          <div class="shop_table-row"><div class="shop_table-cell listheading">[% 'Department' | $T8 %]</div><div class="shop_table-cell">[% HTML.escape(IMPORT.delivery_department) %]</div></div>
84
            [% SET delivery = IMPORT.delivery_firstname _ ' ' _ IMPORT.delivery_lastname %]
85
          <hr>
86
          <div class="shop_table-row"><div class="shop_table-cell listheading">[% 'Greeting' | $T8 %]</div><div class="shop_table-cell">[% L.input_tag('delivery_greeting', IMPORT.delivery_greeting) %]</div></div>
87
          <div class="shop_table-row"><div class="shop_table-cell listheading">[% 'Customer' | $T8 %]</div><div class="shop_table-cell">[% L.input_tag('delivery_name', delivery) %]</div></div>
88
          <div class="shop_table-row"><div class="shop_table-cell listheading">[% 'Name 2' | $T8 %]</div><div class="shop_table-cell">[% L.input_tag('delivery_company', IMPORT.delivery_company) %]</div></div>
89
          <div class="shop_table-row"><div class="shop_table-cell listheading">[% 'Name 3' | $T8 %]</div><div class="shop_table-cell">[% L.input_tag('delivery_department', IMPORT.delivery_department) %]</div></div>
90
          <div class="shop_table-row"><div class="shop_table-cell listheading">[% 'Street' | $T8 %]</div><div class="shop_table-cell">[% L.input_tag('delivery_street', IMPORT.delivery_street) %]</div></div>
91
          <div class="shop_table-row"><div class="shop_table-cell listheading">[% 'Zipcode' | $T8 %]</div><div class="shop_table-cell">[% L.input_tag('delivery_zipcode', IMPORT.delivery_zipcode) %]</div></div>
92
          <div class="shop_table-row"><div class="shop_table-cell listheading">[% 'City' | $T8 %]</div><div class="shop_table-cell">[% L.input_tag('delivery_city', IMPORT.delivery_city) %]</div></div>
93
          <div class="shop_table-row"><div class="shop_table-cell listheading">[% 'Country' | $T8 %]</div><div class="shop_table-cell">[% L.input_tag('delivery_country', IMPORT.delivery_country) %]</div></div>
94
          <div class="shop_table-row"><div class="shop_table-cell listheading">[% 'Phone' | $T8 %]</div><div class="shop_table-cell">[% L.input_tag('delivery_phone', IMPORT.delivery_phone) %]</div></div>
95
          <div class="shop_table-row"><div class="shop_table-cell listheading">[% 'Email' | $T8 %]</div><div class="shop_table-cell">[% L.input_tag('delivery_email', IMPORT.delivery_email) %]</div></div>
96
          [% IF D_ADDRESS %]
97
          <div class="shop_table-row"><div class="shop_table-cell listheading">[% 'Customernumber' | $T8 %]</div><div class="shop_table-cell">[% D_ADDRESS.customernumber %]</div></div>
98
          [% ELSE %]
99
          <div>[% L.ajax_submit_tag("controller.pl?action=ShopOrder/apply_customer",  "#delivery", LxERP.t8("Apply customer")) %]</div>
100
          [% END %]
101
        </div>
102
      </form>
103
      </div>
104
    </div>
105
  </div>
106
  <hr>
107
  <table width="100%">
108
    <tr>
109
      <td width="35%">
110
        <table>
111
          <tr class="listheading">
112
            <th colspan="2">[% 'Shop Headdata' | $T8 %]</th>
113
          </tr>
114
          <tr><td><b>[% 'Shop Ordernumber' | $T8 %]</b></td><td>[% HTML.escape(IMPORT.shop_ordernumber) %]</td></tr>
115
          <tr><td><b>[% 'Shop Orderdate' | $T8 %]</b></td><td>[% HTML.escape(IMPORT.order_date.dmy('.')) _ ' ' _ HTML.escape(IMPORT.order_date.hms(':')) %]</td></tr>
116
          <tr><td><b>[% 'Shop Host' | $T8 %]</b></td><td>[% HTML.escape(IMPORT.host) %]</td></tr>
117
          <tr><td><b>[% 'Shop OrderIP' | $T8 %]</b></td><td>[% HTML.escape(IMPORT.remote_ip) %]</td></tr>
118
          <tr><td><b>[% 'Shop Ordernotes' | $T8 %]</b></td><td>[% HTML.escape(IMPORT.shop_customer_comment) %]</td></tr>
119
          <tr><td><b>[% 'Shop Orderamount' | $T8 %]</b></td><td>[% HTML.escape(IMPORT.amount_as_number) %]</td></tr>
120
          <tr><td><b>[% 'Shipping costs' | $T8 %]</b></td><td>[% HTML.escape(IMPORT.shipping_costs_as_number) %]</td></tr>
121
        </table>
122
      </td>
123
      <td style="padding-left: 20px; vertical-align: top;">
124
        [% IF IMPORT.obsolete %]
125
        <b>[% 'Shoporder deleted -- ' | $T8 %]</b><a href="controller.pl?action=ShopOrder/undelete_order&import_id=[% IMPORT.id %]">[% 'revert deleted' | $T8 %]</a>
126
        [% ELSE %]
127
        [% UNLESS IMPORT.transferred %]
128
        [% IF PROPOSALS %]
129
          <form method="post" action="controller.pl" id="create_order">
130
            [% L.hidden_tag('import_id', IMPORT.id) %]
131
            <div style="height: 125px; overflow:auto;">
132
              <table>
133
                <tr class="listheading">
134
                  <th colspan="7">Customer Proposals</td>
135
                </tr>
136
                [% FOREACH prop = PROPOSALS %][% IF prop.order_lock %][% SET orderlock_class = 'style="background:rgba(232, 32, 23, 0.2);"' %][% ELSE %][% SET orderlock_class = '' %][% END %]
137
                <tr class="listrow" [% orderlock_class %]>
138
                  <td>[% IF !prop.order_lock %][% L.radio_button_tag('customer', value=prop.id) %][% END %]</td>
139
                  <td><a href="controller.pl?action=CustomerVendor/edit&id=[% prop.id %]&db=customer&callback=[% HTML.url('controller.pl?action=ShopOrder/show&id=' _ IMPORT.id) %]">[% HTML.escape(prop.customernumber) %]</a></td>
140
                  <td>[% IF !prop.notes == '' %]<span class="tooltipster-html" title="[% HTML.escape(prop.notes) %]"><span style="color:red;font-weight: bold;">[% HTML.escape(prop.name) %]</span>[% ELSE %][% HTML.escape(prop.name) %][% END %]</td>
141
                  <td>[% HTML.escape(prop.street) %]</td>
142
                  <td>[% HTML.escape(prop.zipcode) %]</td>
143
                  <td>[% HTML.escape(prop.city) %]</td>
144
                  <td>[% HTML.escape(prop.email) %]</td>
145
                </tr>
146
                [% END %]
147
              </table>
148
            </div>
149
            <div id="transfer" style="float:left; display:none;">
150
              [% # 'Customernumber: ' _ %]
151
              [% L.ajax_submit_tag('controller.pl?action=ShopOrder/transfer', "#create_order", LxERP.t8('Create order')) %]
152
            </div>
153
            [% FOREACH prop = PROPOSALS %]
154
            <div id="shop_update_customer_[% prop.id %]" class="div_hidden" style="display:none;">
155
              [% L.ajax_submit_tag("controller.pl?action=ShopOrder/apply_customer&cv_id=" _ prop.id,  "#billing", LxERP.t8("Update customer using billing address")) %]
156
            </div>
157
            [% END %]
158
          </form>
159
        <a href="controller.pl?action=ShopOrder/delete_order&import_id=[% IMPORT.id %]">[% 'delete order' | $T8 %]</a>
160
        [% END # PROPOSALS %]
161
        [% ELSE %]
162
        <div>
163
          [% 'Transferred' | $T8 %]
164
          <div id="recordlinks"></div>
165
          <script type="text/javascript">
166
            var url = 'controller.pl?action=RecordLinks/ajax_list&object_model=ShopOrder&object_id=[% IMPORT.id %]';
167
            $('#recordlinks').load(url);
168
          </script>
169
        </div>
170
        [% END %]
171
        [% END %]
172
      </td>
173
    </tr>
174
  </table>
175
  <hr>
176
  <div style="height: 250px; overflow:auto; margin:15px;">
177
    <table width="99%">
178
      <tr class="listheading">
179
        <th>[% 'Position' | $T8 %]</th>
180
        <th>[% 'Partnumber' | $T8 %]</th>
181
        <th>[% 'Part Description' | $T8 %]</th>
182
        <th>[% 'Qty' | $T8 %]</th>
183
        <th>[% 'Price' | $T8 %]</th>
184
        <th>[% 'Extended' | $T8 %]</th>
185
      </tr>
186
      [% FOREACH pos = IMPORT.shop_order_items %]
187
      <tr class="listrow">
188
        <td>[% count() %]</td>
189
        <td>[% HTML.escape(pos.partnumber) %]</td>
190
        <td>[% HTML.escape(pos.description) %]</td>
191
        <td>[% pos.quantity_as_number%]</td>
192
        <td>[% pos.price_as_number%]</td>
193
        [% SET extended = pos.price * pos.quantity %]
194
        <td>[% LxERP.format_amount(extended,2) %]</td>
195
      </tr>
196
      [% END %]
197
    </table>
198
  </div>
199
  <hr>
200
<script type="text/javascript">
201
$("input[type=radio]").change(function(){
202
      $('.div_hidden').css("display", 'none');
203
      var cv_id = $("input[type=radio][id="+ this.id + "]").val();
204
      $('#shop_update_customer_'+ cv_id).css("display", 'block');
205
      $('#transfer').css("display", 'block');
206
});
207
</script>
208
[% # L.dump(IMPORT) %]

Auch abrufbar als: Unified diff