Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 7b03930b

Von Werner Hahn vor etwa 7 Jahren hinzugefügt

  • ID 7b03930ba3452d17c42a23958fbb0b85e350d48c
  • Vorgänger de7d54fb
  • Nachfolger c9ba2b5b

Shopmodul: Anpassungen nach mergen für master
Bis hier noch mit individuellen Kundenanpassungen

Unterschiede anzeigen:

SL/BackgroundJob/ShopOrderMassTransfer.pm
1 1
package SL::BackgroundJob::ShopOrderMassTransfer;
2
#BackgroundJob::ShopOrderMassTransfer
2

  
3 3
use strict;
4 4
use warnings;
5 5

  
......
27 27
# my $data                  = {
28 28
#     shop_order_record_ids       => [ 603, 604, 605],
29 29
#     num_order_created           => 0,
30
#     num_delivery_order_created  => 0,
30
#     orders_ids                  => [1,2,3]
31 31
#     conversation_errors         => [ { id => 603 , item => 2, message => "Out of stock"}, ],
32 32
# };
33 33
#
......
45 45
    # die "can't find shoporder with id $shop_order_id" unless $shop_order;
46 46
    #TODO Kundenabfrage so ändern, dass es nicht abricht
47 47
    unless($shop_order){
48
      push @{ $error_report{$shop_order_id}} }, 'Shoporder not found';
48
      push @{ $error_report{$shop_order_id} }, 'Shoporder not found';
49 49
    }
50 50
    my $customer = SL::DB::Manager::Customer->find_by(id => $shop_order->{kivi_customer_id});
51 51
    die "Can't find customer" unless $customer;
......
80 80
      $shop_order->oe_transid($order->id);
81 81
      $shop_order->save;
82 82
      $shop_order->link_to_record($order);
83
      $data->{num_created}++;
83
      $data->{num_order_created} ++;
84 84
      push @{ $data->{orders_ids} }, $order->id;
85 85
      push @{ $data->{shop_orders_ids} }, $shop_order->id;
86 86

  
87
      $job_obj->update_attributes(data_as_hash => $data);
87 88
      my $delivery_order = $order->convert_to_delivery_order(customer => $customer, employee => $employee);
88 89
      $delivery_order->save;
89 90
      my $snumbers = "deliveryordernumber_" . $delivery_order->donumber;
SL/Controller/FileUploader.pm
21 21
  $self->render('fileuploader/test_page');
22 22
}
23 23

  
24
sub action_upload_form{
25
  my ($self) = @_;
26
  $self->file(SL::DB::File->new);
27
  $self->render('common/file_upload', {header => 0});
28
}
29

  
30
sub action_show_files {
31
  my ($self) = @_;
32
$main::lxdebug->dump(0, 'WH: Show_Files',\$::form);
33
  my $images = SL::DB::Manager::File->get_all( query => [ trans_id => $::form->{id}, modul => $::form->{modul} ] );
34
  $main::lxdebug->dump(0, 'WH: ',\$images);
35

  
36

  
37
}
38

  
39 24
sub action_ajax_add_file{
40 25
  my ($self) = @_;
41 26
  $self->file( $::form->{id} ? SL::DB::File->new(id => $::form->{id})->load : SL::DB::File->new );
......
60 45
  return @errors
61 46
}
62 47

  
63
sub action_upload_form{
64
  my ($self) = @_;
65
  $self->file(SL::DB::File->new);
66
  $self->render('common/file_upload', {header => 0});
67
}
68

  
69
sub action_show_files {
70
  my ($self) = @_;
71

  
72

  
73
sub action_ajax_add_file{
74
  my ($self) = @_;
75
  $self->file(SL::DB::File->new);
76
  $self->render('common/file_upload', { layout => 0}, DATA => $::form);
77
}
78

  
79
sub action_ajax_upload_file{
80
  my ($self, %params) = @_;
81
  my $attributes                  = $::form->{ $::form->{form_prefix} } || die "Missing FormPrefix";
82
  $attributes->{trans_id}         = $::form->{id} || die "Missing ID";
83
  $attributes->{modul}            = $::form->{modul} || die "Missing Modul";
84
  $attributes->{filename}         = $::form->{FILENAME} || die "Missing Filename";
85
  $attributes->{title}            = $::form->{ $::form->{form_prefix} }->{title};
86
  $attributes->{description}      = $::form->{ $::form->{form_prefix} }->{description};
87
  my @image_types = ("jpg","tif","png");
88

  
89
  my @errors = $self->file(SL::DB::File->new(%{ $attributes }))->validate;
90
  return $self->js->error(@errors)->render($self) if @errors;
91

  
92
  $self->file->save;
93

  
94
  # TODO js call
95
  $self->render('fileuploader/test_page');
96
}
97

  
98
#
99
# helpers
100
#
101

  
102 48
sub init_file {
103 49
  return SL::DB::File->new(id => $::form->{id})->load;
104 50
}
......
122 68

  
123 69
=head1 DESCRIPTION
124 70

  
125
# longer description...
71
 just the action ajax_add_file is needed and its automaticly called by. The other ones are for the testpage templates/webpages/testpage.html
72
 kivi.add.file(id[shop_part_id,part_id, cv_id, project_id,...],modul[part,shop_part,project,IC,...],controller_action[ShopPart/do_something_file],allowed_filestypes) in your template.
73
 [% L.button_tag("kivi.add_file(this.form.id.value,'shop_part', 'Part/do_something_with_file','jpg,png,gif,pdf')", 'Fileupload') %]
74

  
75
 The called Controller/Action deals with the uploaded file in wich you can do whatever you want with the file.
76
 like
77
 - Store it in the Database SL::DB::File
78
 - Store it in Webdav
79
 - Store it in Webdav and DB (be careful: files wich deleted in the filesystem will not be deleted in the database automaticly)
80
 - do something very fancy with the file
126 81

  
127 82

  
128 83
=head1 INTERFACE
SL/Controller/ShopOrder.pm
1 1
package SL::Controller::ShopOrder;
2
#package SL::Controller::ShopOrder;
3
# Controller::ShopOrder
4 2

  
5 3
use strict;
6 4

  
......
43 41
  my ( $self ) = @_;
44 42
  my %filter = ($::form->{filter} ? parse_filter($::form->{filter}) : query => [ transferred => 0, obsolete => 0 ]);
45 43
  my $transferred = $::form->{filter}->{transferred_eq_ignore_empty} ne '' ? $::form->{filter}->{transferred_eq_ignore_empty} : '';
46
  #$::lxdebug->dump(0, "WH: FILTER ",  $::form->{filter}->{_eq_ignore_empty}." - ".$transferred);
47
  #$::lxdebug->dump(0, "WH: FILTER2 ",  \%filter);
48 44
  my $sort_by = $::form->{sort_by} ? $::form->{sort_by} : 'order_date';
49 45
  $sort_by .=$::form->{sort_dir} ? ' DESC' : ' ASC';
50 46
  my $shop_orders = SL::DB::Manager::ShopOrder->get_all( %filter, sort_by => $sort_by,
......
61 57
    );
62 58
    $shop_order->{open_invoices} = $open_invoices;
63 59
  }
64
  $main::lxdebug->dump(0, 'WH:SHOPORDER ',\$shop_orders);
65

  
66 60

  
67 61
  $self->render('shop_order/list',
68 62
                title       => t8('ShopOrders'),
......
116 110
                            and => [ # check for street and zipcode
117 111
                                     and => [ 'street'  => { ilike => "%".$shop_order->customer_street."%" },
118 112
                                              'zipcode' => { ilike => $shop_order->customer_zipcode },
113
                                            ],
114
                                   ],
119 115
                            or  => [ 'email' => { ilike => $shop_order->customer_email } ],
120 116
                         ],
121 117
                ],
122 118
  );
123
  $main::lxdebug->dump(0, 'WH:PROP ',\$proposals);
124

  
125 119

  
126 120
  $self->render('shop_order/show',
127 121
                title       => t8('Shoporder'),
......
287 281
                                           'zipcode'=> { ilike => $address{'zipcode'} },
288 282
                                           'city'   => { ilike => $address{'city'} },
289 283
                                         ]);
290
  $::lxdebug->dump(0, "WH: CUSTOMER ", \$addressdata);
291 284
  return @{$addressdata}[0];
292 285
}
293 286

  
SL/Controller/ShopPart.pm
1 1
package SL::Controller::ShopPart;
2
#package SL::Controller::ShopPart;
3 2

  
4 3
use strict;
5 4

  
......
181 180
    my $shop_article = $shop->connector->get_article($self->shop_part->part->partnumber);
182 181
    $stock_onlineshop = $shop_article->{data}->{mainDetail}->{inStock};
183 182
    $active_online = $shop_article->{data}->{active};
184
    #}
183
  }
185 184

  
186 185
  $stock_local = $self->shop_part->part->onhand;
187 186

  
......
234 233

  
235 234
  #TODO Price must be formatted. $price_src_str must be translated
236 235
  flash('info', $is_new ? t8('The shop part has been created.') : t8('The shop part has been saved.'));
237
  # $self->js->val('#partnumber', 'ladida');
238 236
  $self->js->html('#shop_part_description_' . $self->shop_part->id, $self->shop_part->shop_description)
239 237
           ->html('#shop_part_active_' . $self->shop_part->id, $self->shop_part->active)
240 238
           ->html('#price_' . $self->shop_part->id, $::form->format_amount(\%::myconfig,$price,2))
......
307 305
  my $transferred = $::form->{filter}->{transferred_eq_ignore_empty} ne '' ? $::form->{filter}->{transferred_eq_ignore_empty} : '';
308 306
  my $sort_by = $::form->{sort_by} ? $::form->{sort_by} : 'part.partnumber';
309 307
  $sort_by .=$::form->{sort_dir} ? ' DESC' : ' ASC';
310
$main::lxdebug->message(0, "WH:LA ");
311 308

  
312 309
  my $articles = SL::DB::Manager::ShopPart->get_all(where => [ 'shop.obsolete' => 0 ],with_objects => [ 'part','shop' ], sort_by => $sort_by );
313 310

  
......
315 312
    my $images = SL::DB::Manager::File->get_all_count( where => [ trans_id => $article->part->id, modul => 'shop_part', file_content_type => { like => 'image/%' } ], sort_by => 'position' );
316 313
    $article->{images} = $images;
317 314
  }
318
  $main::lxdebug->dump(0, 'WH:ARTIKEL ',\$articles);
319 315

  
320 316
  $self->render('shop_part/_list_articles', title => t8('Webshops articles'), SHOP_PARTS => $articles);
321 317
}
......
332 328

  
333 329
sub action_mass_upload {
334 330
  my ($self) = @_;
335
$main::lxdebug->message(0, "WH:MA ");
336 331

  
337 332
  my @shop_parts =  @{ $::form->{shop_parts_ids} || [] };
338 333

  
......
346 341
     status                       => SL::BackgroundJob::ShopPartMassUpload->WAITING_FOR_EXECUTION(),
347 342
     conversation_errors          => [ ],
348 343
   )->update_next_run_at;
349
$main::lxdebug->dump(0, 'WH:MA JOB ',\$job);
350 344

  
351 345
   SL::System::TaskServer->new->wake_up;
352
$main::lxdebug->dump(0, 'WH:MA JOB 2',\$job);
353 346

  
354 347
   my $html = $self->render('shop_part/_transfer_status', { output => 0 }, job => $job);
355 348

  
......
363 356
# internal stuff
364 357
#
365 358
sub add_javascripts  {
366
  # is this needed?
367 359
  $::request->{layout}->add_javascripts(qw(kivi.shop_part.js));
368 360
}
369 361

  
......
422 414
}
423 415

  
424 416
sub init_file {
425
  $main::lxdebug->message(0, "WH:INIT_FILES ");
426 417
  my $file = $::form->{id} ? SL::DB::File->new(id => $::form->{id})->load : SL::DB::File->new;
427
  $main::lxdebug->dump(0, 'WH: INITFILE: ',\file);
428

  
429 418
  return $file;
430 419
}
431 420

  
432 421
sub init_shops {
433 422
  # data for drop down filter options
434
  $main::lxdebug->message(0, "WH:INIT_SHOPS ");
435

  
436 423
  require SL::DB::Shop;
437 424
  my @shops_dd = [ { title => t8("all") ,   value =>'' } ];
438 425
  my $shops = SL::DB::Mangager::Shop->get_all( where => [ obsolete => 0 ] );
439
   my @tmp = map { { title => $_->{description}, value => $_->{id} } } @{ $shops } ;
440
 $main::lxdebug->dump(0, 'WH:SHOPS ',\@tmp);
441
 return @shops_dd;
426
  my @tmp = map { { title => $_->{description}, value => $_->{id} } } @{ $shops } ;
427
  return @shops_dd;
442 428

  
443 429
}
444 430

  
445 431
sub init_producers {
446 432
  # data for drop down filter options
447
  $main::lxdebug->message(0, "WH:INIT_PRODUCERS ");
448

  
449 433
  my @producers_dd = [ { title => t8("all") ,   value =>'' } ];
450
 return @producers_dd;
434
  return @producers_dd;
451 435

  
452 436
}
453 437

  
SL/DB/File.pm
2 2
# Feel free to modify it at will; it will not be overwritten automatically.
3 3

  
4 4
package SL::DB::File;
5
#package SL::DB::File;
6 5

  
7 6
use strict;
8 7

  
SL/DB/Helper/ThumbnailCreator.pm
2 2

  
3 3
use strict;
4 4

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

  
7
use SL::Locale::String qw(t8);
5 8
use Carp;
6 9
use GD;
7 10
use Image::Info;
......
79 82
  my ($self) = @_;
80 83

  
81 84
  return () if !$self->file_content;
82
  return () if $self->file_content_type && $self->file_img_width && $self->file_img_height && !Rose::DB::Object::Util::get_column_value_modified($self, 'file_content');
85
  return () if $self->file_content_type && $self->files_img_width && $self->files_img_height && !Rose::DB::Object::Util::get_column_value_modified($self, 'file_content');
83 86

  
84 87
  my @errors = $self->file_probe_type;
85 88
  return @errors if @errors;
......
102 105

  
103 106
=head1 NAME
104 107

  
105
SL::DB::Helper::ThumbnailCreator - DatabaseClass Helper for Fileuploads
108
  SL::DB::Helper::ThumbnailCreator - DatabaseClass Helper for Fileuploads
106 109

  
107 110
=head1 SYNOPSIS
108 111

  
......
112 115

  
113 116
=head1 DESCRIPTION
114 117

  
115
# longer description..
118
  # longer description..
119

  
116 120
=head1 AUTHOR
117 121

  
118
Werner Hahn E<lt>wh@futureworldsearch.netE<gt>
122
  Werner Hahn E<lt>wh@futureworldsearch.netE<gt>
119 123

  
120 124
=cut
121 125

  
SL/DB/MetaSetup/Shop.pm
1 1
# This file has been auto-generated. Do not modify it; it will be overwritten
2 2
# by rose_auto_create_model.pl automatically.
3 3
package SL::DB::Shop;
4
#package SL::DB::Shop;
5 4

  
6 5
use strict;
7 6

  
8
use base qw(SL::DB::Object);
7
use parent qw(SL::DB::Object);
9 8

  
10 9
__PACKAGE__->meta->table('shops');
11 10

  
SL/DB/MetaSetup/ShopOrder.pm
1 1
# This file has been auto-generated. Do not modify it; it will be overwritten
2 2
# by rose_auto_create_model.pl automatically.
3 3
package SL::DB::ShopOrder;
4
#package SL::DB::ShopOrder;
5 4

  
6 5
use strict;
7 6

  
SL/DB/MetaSetup/ShopOrderItem.pm
1 1
# This file has been auto-generated. Do not modify it; it will be overwritten
2 2
# by rose_auto_create_model.pl automatically.
3 3
package SL::DB::ShopOrderItem;
4
#package SL::DB::ShopOrderItem;
5 4

  
6 5
use strict;
7 6

  
SL/DB/MetaSetup/ShopPart.pm
1 1
# This file has been auto-generated. Do not modify it; it will be overwritten
2 2
# by rose_auto_create_model.pl automatically.
3 3
package SL::DB::ShopPart;
4
#package SL::DB::ShopPart;
5 4

  
6 5
use strict;
7 6

  
8
<<<<<<< HEAD
9 7
use parent qw(SL::DB::Object);
10
=======
11
use base qw(SL::DB::Object);
12
>>>>>>> Shop - Einführung von ShopParts
13 8

  
14 9
__PACKAGE__->meta->table('shop_parts');
15 10

  
SL/DB/Part.pm
1 1
package SL::DB::Part;
2
#package SL::DB::Part;
3 2

  
4 3
use strict;
5 4

  
......
134 133
sub is_assortment { $_[0]->part_type eq 'assortment' }
135 134

  
136 135
sub type {
137
  return $_[0]->part_type;
138
  # my ($self, $type) = @_;
139
  # if (@_ > 1) {
140
  #   die 'invalid type' unless $type =~ /^(?:part|service|assembly)$/;
141
  #   $self->assembly(          $type eq 'assembly' ? 1 : 0);
142
  #   $self->inventory_accno_id($type ne 'service'  ? 1 : undef);
143
  # }
144

  
145
  # return 'assembly' if $self->assembly;
146
  # return 'part'     if $self->inventory_accno_id;
147
  # return 'service';
136
  my ($self, $type) = @_;
137
  if (@_ > 1) {
138
    die 'invalid type' unless $type =~ /^(?:part|service|assembly)$/;
139
    $self->assembly(          $type eq 'assembly' ? 1 : 0);
140
    $self->inventory_accno_id($type ne 'service'  ? 1 : undef);
141
  }
142

  
143
  return 'assembly' if $self->assembly;
144
  return 'part'     if $self->inventory_accno_id;
145
  return 'service';
148 146
}
149 147

  
150 148
sub new_part {
SL/DB/ShopOrder.pm
2 2
# Feel free to modify it at will; it will not be overwritten automatically.
3 3

  
4 4
package SL::DB::ShopOrder;
5
# DB::ShopOrder
6 5

  
7 6
use strict;
8 7

  
SL/DB/ShopPart.pm
13 13
__PACKAGE__->meta->initialize;
14 14
__PACKAGE__->attr_html('shop_description');
15 15

  
16

  
16 17
1;
SL/Shop.pm
1 1
package SL::Shop;
2
#package SL::Shop;
3 2

  
4 3
use strict;
5 4

  
6 5
use parent qw(Rose::Object);
6
use SL::ShopConnector::ALL;
7
use SL::DB::Part;
7 8

  
8 9
# __PACKAGE__->run_before('check_auth');
9 10

  
......
12 13
  'scalar --get_set_init' => [ qw(connector) ],
13 14
);
14 15

  
16
sub updatable_parts {
17
  my ($self, $last_update) = @_;
18
  $last_update ||= DateTime->now(); # need exact timestamp, with minutes
19

  
20
  my $parts;
21
  my $active_shops = SL::DB::Manager::Shop->get_all(query => [ obsolete => 0 ]);
22
  foreach my $shop ( @{ $active_shops } ) {
23
    # maybe run as an iterator? does that make sense with with_objects?
24
    my $update_parts = SL::DB::Manager::ShopPart->get_all(query => [
25
             and => [
26
                'active' => 1,
27
                'shop_id' => $shop->id,
28
                # shop => '1',
29
                or => [ 'part.mtime' => { ge => $last_update },
30
                        'part.itime' => { ge => $last_update },
31
                        'itime'      => { ge => $last_update },
32
                        'mtime'      => { ge => $last_update },
33
                      ],
34
                    ]
35
             ],
36
             with_objects => ['shop', 'part'],
37
             # multi_many_ok   => 1,
38
          );
39
    push( @{ $parts }, @{ $update_parts });
40
  };
41
  return $parts;
42

  
43
};
44

  
15 45
sub init_connector {
16 46
  my ($self) = @_;
17 47
  # determine the connector from the connector type in the webshop config
18
  return SL::ShopConnector::ALL->shop_connector_class_by_name($self->config->connector)->new( config => $self->config); 
48
  return SL::ShopConnector::ALL->shop_connector_class_by_name($self->config->connector)->new( config => $self->config);
19 49

  
20 50
};
21 51

  
......
27 57

  
28 58
=head1 NAME
29 59

  
30
SL::WebShop - Do stuff with WebShop instances
60
  SL::Shop - Do stuff with WebShop instances
31 61

  
32 62
=head1 SYNOPSIS
33 63

  
34
  my $config = SL::DB::Manager::WebShop->get_first();
64
  my $config = SL::DB::Manager::Shop->get_first();
35 65
  my $shop = SL::WebShop->new( config => $config );
36 66

  
37
From the config we know which Connector class to load, save in $shop->connector
38
and do stuff from there:
67
  From the config we know which Connector class to load, save in $shop->connector
68
  and do stuff from there:
39 69

  
40 70
  $shop->connector->get_new_orders;
41 71

  
......
43 73

  
44 74
=head1 BUGS
45 75

  
46
Nothing here yet.
76
  Nothing here yet.
47 77

  
48 78
=head1 AUTHOR
49 79

  
50
G. Richardson <lt>information@kivitendo-premium.deE<gt>
80
  G. Richardson <lt>information@kivitendo-premium.deE<gt>
51 81

  
52 82
=cut
53

  
SL/ShopConnector/Shopware.pm
1 1
package SL::ShopConnector::Shopware;
2
#package SL::ShopConnector::Shopware;
3
#package SL::ShopConnector::Shopware;
4 2

  
5 3
use strict;
6 4

  
......
249 247
  return \@daten;
250 248
}
251 249

  
250
sub get_articles {
251
  my ($self, $json_data) = @_;
252

  
253
}
254

  
255

  
252 256
sub update_part {
253 257
  my ($self, $shop_part, $json, $todo) = @_;
254 258

  
......
316 320

  
317 321
  # mapping to shopware still missing attributes,metatags
318 322
  my %shop_data;
319
  $main::lxdebug->dump(0, 'WH:TODO ',\$todo);
320 323

  
321 324
  if($todo eq "price"){
322 325
    %shop_data = ( mainDetail => { number   => $part->{partnumber},
......
375 378
  }else{
376 379
    my %shop_data =  ( mainDetail => { number   => $part->{partnumber}, });
377 380
  }
378
  $main::lxdebug->dump(0, 'WH:SHOPDATA ',\%shop_data);
379 381

  
380 382
  my $dataString = SL::JSON::to_json(\%shop_data);
381 383
  $dataString = encode_utf8($dataString);
382 384

  
383 385
  my $upload_content;
384 386
  if($import->{success}){
385
  my %del_img =  ( images        => [ {} ], ) ;
386
  my $del_imgString = SL::JSON::to_json(\%del_img);
387
  #my $delImg = $self->connector->put("http://$url/api/articles/$part->{partnumber}?useNumberAsId=true",Content => $del_imgString);
388 387
    #update
389 388
    my $partnumber = $::form->escape($part->{partnumber});#shopware don't accept / in articlenumber
390 389
    my $upload = $self->connector->put("http://$url/api/articles/$partnumber?useNumberAsId=true",Content => $dataString);
......
408 407
  my ($self,$partnumber) = @_;
409 408

  
410 409
  my $url = $self->url;
411
  my $partnumber = $::form->escape($partnumber);#shopware don't accept / in articlenumber
410
  $partnumber = $::form->escape($partnumber);#shopware don't accept / in articlenumber
412 411
  my $data = $self->connector->get("http://$url/api/articles/$partnumber?useNumberAsId=true");
413 412
  my $data_json = $data->content;
414 413
  return SL::JSON::decode_json($data_json);
css/webshop.css
1
/* Shop */
2 1
div.shop_table {
3 2
  display: table;
4 3
  background-color: #ebebeb;
js/kivi.FileUploader.js
1
//TMP
2 1
namespace('kivi.FileUploader', function(ns) {
3 2
  //opens a popupdialog for fileupload
4 3

  
js/kivi.ShopOrder.js
1
//TMP
2 1
namespace('kivi.ShopOrder', function(ns) {
3 2
  ns.massTransferInitialize = function() {
4 3
    kivi.popup_dialog({
5 4
      id: 'status_mass_transfer',
6 5
      dialog: {
7
        title: kivi.t8('Status Shoptransfer')
6
        title: kivi.t8('Status Shoptransfer'),
7
        close: function(event, ui) { alert('CLOSE'); },
8 8
      }
9 9
    });
10
    alert('Hallo');
11 10
  };
12 11

  
13 12
  ns.massTransferStarted = function() {
......
24 23
    $('.ui-dialog-titlebar button.ui-dialog-titlebar-close').prop('disabled', '')
25 24
  };
26 25

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

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

  
32 36
});
33
//$(kivi.ShopOrder.setup);
js/kivi.shop_part.js
1
//TMP
2 1
namespace('kivi.shop_part', function(ns) {
3 2
  var $dialog;
4 3

  
......
30 29
  }
31 30

  
32 31

  
33
    // save existing shop_part_id with new params from form, calls create_or_update and saves to db
34
    ns.save_shop_part = function(shop_part_id) {
35
      var form = $('form').serializeArray();
36
      form.push( { name: 'action', value: 'ShopPart/update' }
37
               , { name: 'shop_part_id',  value: shop_part_id }
38
      );
39

  
40
      $.post('controller.pl', form, function(data) {
41
        kivi.eval_json_result(data);
42
      });
43
    }
32
  // save existing shop_part_id with new params from form, calls create_or_update and saves to db
33
  ns.save_shop_part = function(shop_part_id) {
34
    var form = $('form').serializeArray();
35
    form.push( { name: 'action', value: 'ShopPart/update' }
36
             , { name: 'shop_part_id',  value: shop_part_id }
37
    );
44 38

  
45
    // add part to a shop
46
    ns.add_shop_part = function(part_id,shop_id) {
47
      var form = $('form').serializeArray();
48
      form.push( { name: 'action', value: 'ShopPart/update' }
49
      );
39
    $.post('controller.pl', form, function(data) {
40
      kivi.eval_json_result(data);
41
    });
42
  }
50 43

  
51
      $.post('controller.pl', form, function(data) {
52
        kivi.eval_json_result(data);
53
      });
54
    }
44
  // add part to a shop
45
  ns.add_shop_part = function(part_id,shop_id) {
46
    var form = $('form').serializeArray();
47
    form.push( { name: 'action', value: 'ShopPart/update' }
48
    );
49
    $.post('controller.pl', form, function(data) {
50
      kivi.eval_json_result(data);
51
    });
52
  }
55 53

  
56 54
  // this is called from tabs/_shop.html, opens edit_window (render)
57 55
  ns.edit_shop_part = function(shop_part_id) {
......
121 119
    });
122 120
  }
123 121

  
122
  ns.massUploadInitialize = function() {
123
    kivi.popup_dialog({
124
      id: 'status_mass_upload',
125
      dialog: {
126
        title: kivi.t8('Status Shopupload')
127
      }
128
    });
129
  };
130

  
131
  ns.massUploadStarted = function() {
132
    $('#status_mass_upload').data('timerId', setInterval(function() {
133
      $.get("controller.pl", {
134
        action: 'ShopPart/upload_status',
135
        job_id: $('#smu_job_id').val()
136
      }, kivi.eval_json_result);
137
    }, 5000));
138
  };
139

  
140
  ns.massUploadFinished = function() {
141
    clearInterval($('#status_mass_upload').data('timerId'));
142
    $('.ui-dialog-titlebar button.ui-dialog-titlebar-close').prop('disabled', '')
143
  };
144

  
145
  ns.setup = function() {
146
    kivi.shop_part.massUploadInitialize();
147
    kivi.submit_ajax_form('controller.pl?action=ShopPart/mass_upload','[name=shop_parts]');
148
  };
149

  
124 150
});
menus/user/10-shopimport.yaml
18 18
    action: ShopPart/list_articles
19 19
    db: shop_parts
20 20
    sort_by: part.onhand
21
#ShopPart
sql/Pg-upgrade2/shop_orders_2.sql
1 1
-- @tag: shop_orders_2
2 2
-- @description: Hinzufügen der Spalte Position in der Tabelle shop_order_items
3 3
-- @depends: release_3_3_0
4
-- tmp
5 4
ALTER TABLE shop_order_items ADD COLUMN position integer;
sql/Pg-upgrade2/shop_parts.sql
1
-- TMP
2 1
-- @tag: shop_parts
3 2
-- @description: Add tables for part information for shop
4 3
-- @charset: UTF-8
templates/webpages/common/file_upload.html
1
<!-- TMP -->
2 1
[%- USE LxERP -%][%- USE L -%][%- USE HTML -%][%- USE JavaScript -%][% USE Base64 %]
3 2
[% SET style="width: 500px" %]
4
[% SET id_base = "fileupload" %]
5
[% L.dump(DATA) %]
3
[% SET id_base_bak  = "fileupload" %]
4
[% SET id_base      = 'fileupload_' _ (SELF.file.id ? SELF.file.id : 'new') %]
5
[% SET trans_id     = SELF.file.id ? SELF.file.trans_id : data.trans_id %]
6
[% SET modul        = SELF.file.id ? SELF.file.modul : data.modul %]
7

  
6 8
<form method="post" id="fileupload_form" method="POST" enctype="multipart/form-data">
7
 [% L.hidden_tag('form_prefix',                    id_base,         id=id_base _ '_form_prefix') %]
8
 [% L.hidden_tag('id',                             DATA.id, no_id=1) %]
9
 [% L.hidden_tag('modul',                          DATA.modul) %]
9
 [% L.hidden_tag('form_prefix',                    id_base,      id=id_base _ '_form_prefix') %]
10
 [% L.hidden_tag(id_base _ '.id',                  SELF.file.id, no_id=1) %]
11
 [% L.hidden_tag(id_base _ '.trans_id',            trans_id) %]
12
 [% L.hidden_tag(id_base _ '.modul',               modul) %]
13
 [% L.hidden_tag('aft',                            data.aft) %]
10 14

  
11 15
 <h2>
12 16
  [%- IF SELF.file.id %]
13
   [%- LxERP.t8("Edit file properties ", SELF.file.number) %]
17
   [%- LxERP.t8("Edit fileproperties", SELF.file.position) %]
14 18
  [%- ELSE %]
15
   [%- LxERP.t8("Add file to webdav") %]
19
   [%- LxERP.t8("Add file") %]
16 20
  [%- END %]
17 21
 </h2>
18 22

  
19 23
 <table>
20
[% IF SELF.file.number %]
24
[% IF SELF.file.id %]
21 25
  <tr>
22
   <th align="right">[%- LxERP.t8("Number") %]:</th>
23
   <td>[% HTML.escape(SELF.file.number) %]</td>
26
   <th align="right">[%- LxERP.t8("Position") %]:</th>
27
   <td>[% HTML.escape(SELF.file.position) %]</td>
24 28
  </tr>
25 29
[% END %]
26 30

  
......
37 41
[% IF SELF.file.file_content %]
38 42
  <tr>
39 43
   <th align="right">[%- LxERP.t8("File name") %]:</th>
40
   <td>[% HTML.escape(SELF.file.file_file_name) %]</td>
44
   <td>[% HTML.escape(SELF.file.filename) %][% L.hidden_tag(id_base _ '.filename', SELF.file.filename) %][% L.hidden_tag('id', SELF.file.id, no_id=1) %]</td>
41 45
  </tr>
42 46

  
43 47
  <tr>
......
47 51

  
48 52
  <tr>
49 53
   <th align="right">[%- LxERP.t8("Dimensions") %]:</th>
50
   <td>[% HTML.escape(SELF.file.file_width) %]x[% HTML.escape(SELF.file.file_height) %]</td>
54
   <td>[% HTML.escape(SELF.file.files_img_width) %]x[% HTML.escape(SELF.file.files_img_height) %]</td>
51 55
  </tr>
52 56

  
53 57
  <tr>
54 58
   <th align="right">[%- LxERP.t8("Uploaded at") %]:</th>
55
   <td>[% HTML.escape(SELF.file.file_mtime.to_kivitendo(precision='second')) %]</td>
59
   <td>[% HTML.escape(SELF.file.files_mtime.to_kivitendo(precision='second')) %]</td>
56 60
  </tr>
57 61
[% END %]
58 62

  
......
63 67
 </table>
64 68

  
65 69
 <p>
66
  [%- L.ajax_submit_tag('controller.pl?action=FileUploader/ajax_upload_file', '#fileupload_form', LxERP.t8('Save'), no_id=1) %]
70
 <!-- TODO action ändern in übergebene Variable, sodass jede xbelibiege Controller/Action aufgerufen werden kann -->
71
  [%- L.ajax_submit_tag('controller.pl?action=' _ data.ca, '#fileupload_form', LxERP.t8('Save'), no_id=1) %]
67 72
  <a href="#" onclick="$('#jqueryui_popup_dialog').dialog('close');">[%- LxERP.t8("Cancel") %]</a>
68 73
 </p>
69 74

  
templates/webpages/shop_order/_transfer_status.html
2 2
[%- USE Dumper -%]
3 3
[% SET data = job.data_as_hash %]
4 4

  
5
<!-- ShopOrder -->
5

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

  
8 8
[% L.hidden_tag('', job.id, id="smt_job_id") %]
......
14 14
[% # Dumper.dump_html(data) %]
15 15
</p>
16 16
<p>
17
 [% L.link("#", LxERP.t8("Close window"), onclick="kivi.ShopOrder.processClose();") %]
17 18
 <table>
18 19
  <tr>
19 20
   <th valign="top" align="left">[% LxERP.t8("Current status:") %]</th>
......
28 29
   </td>
29 30
  </tr>
30 31
  <tr>
31
   <th valign="top" align="left">[% LxERP.t8("Number of invoices created:") %]</th>
32
   <td valign="top">[% IF data.status > 0 %][% HTML.escape(data.num_created) %] / [% HTML.escape(data.record_ids.size) %][% ELSE %]–[% END %]</td>
32
   <th valign="top" align="left">[% LxERP.t8("Number of orders created:") %]</th>
33
   <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 34
  </tr>
34 35

  
35
  <tr>
36
   <th valign="top" align="left">[% LxERP.t8("Number of invoices printed:") %]</th>
37
   <td valign="top">[% IF data.status > 1 %][% HTML.escape(data.num_printed) %] / [% HTML.escape(data.invoice_ids.size) %][% ELSE %]–[% END %]</td>
38
  </tr>
39 36

  
40 37
  <tr>
41 38
   <th valign="top" align="left">[% LxERP.t8("Errors during conversion:") %]</th>
......
61 58
[% END %]
62 59
   </td>
63 60
  </tr>
64

  
65
  <tr>
66
   <th valign="top" align="left">[% LxERP.t8("Errors during printing:") %]</th>
67
   <td valign="top">
68
[% IF data.status < 2 %]
69
70
[% ELSIF !data.print_errors.size %]
71
 [% LxERP.t8("No errors have occurred.") %]
72
[% ELSE %]
73
    <table>
74
     <tr class="listheader">
75
      <th>[% LxERP.t8("Invoice") %]</th>
76
      <th>[% LxERP.t8("Error") %]</th>
77
     </tr>
78

  
79
 [% FOREACH error = data.print_errors %]
80
     <tr>
81
      <td valign="top">[% IF error.id %][% L.link(SELF.url_for(controller='is.pl', action='edit', type='sales_invoice',id=error.id), HTML.escape(error.number), target="_blank") %][% ELSE %]–[% END %]</td>
82
      <td valign="top">[% HTML.escape(error.message) %]</td>
83
     </tr>
84
 [% END %]
85
    </table>
86
[% END %]
87
   </td>
88
  </tr>
89

  
90 61
 </table>
91 62
</p>
templates/webpages/shop_order/list.html
1 1
[%- USE HTML -%][%- USE LxERP -%][%- USE L -%][%- USE T8 -%]
2 2
[% USE Dumper %]
3
<!-- TMP -->
4 3

  
5 4
<h1>[% title %]</h1>
6 5
[%- PROCESS 'shop_order/_filter.html' filter=SELF.models.filtered.laundered %]
......
149 148
      <br>[% HTML.escape(shop_order.customer_street) %]
150 149
      <br>[% HTML.escape(shop_order.customer_zipcode) %]&nbsp;[% HTML.escape(shop_order.customer_city) %]
151 150
      <br>[% HTML.escape(shop_order.customer_country) %] </td>
152
    <td>[% IF shop_order.customer_company %]<b>[% HTML.escape(shop_order.customer_company) %]</b><br>[% END %]
151
    <td [% transferable_class %]>[% IF shop_order.customer_company %]<b>[% HTML.escape(shop_order.customer_company) %]</b><br>[% END %]
153 152
      <b>[% HTML.escape(shop_order.billing_lastname) %],&nbsp;[% HTML.escape(shop_order.billing_firstname) %]</b>
154 153
      <br>[% HTML.escape(shop_order.billing_street) %]
155 154
      <br>[% HTML.escape(shop_order.billing_zipcode) %]&nbsp;[% HTML.escape(shop_order.billing_city) %]
......
181 180
 </table>
182 181
 <hr>
183 182
  <p>
184
   [% L.hidden_tag("action", "ShopOrder/mass_transfer") %]
185
   [% L.submit_tag("", LxERP.t8("Transfer all marked")) %]
183
  [% L.button_tag("kivi.ShopOrder.setup();", LxERP.t8("Transfer all marked"), id="mass_transfer") %]
186 184
  </p>
185
  <div id="status_mass_transfer" style="display: none;">
186
    [%- INCLUDE 'shop_order/_transfer_status.html' %]
187
  </div>
187 188
 </form>
188 189
<script type="text/javascript">
189 190
<!--
templates/webpages/shop_order/show.html
1
<!-- TMP -->
2 1
[%- USE HTML -%][%- USE LxERP -%][%- USE L -%][%- USE T8 -%]
3 2
[% L.stylesheet_tag('webshop') %]
4 3

  
......
208 207
      $('#transfer').css("display", 'block');
209 208
});
210 209
</script>
211
[% L.dump(IMPORT) %]
210
[% # L.dump(IMPORT) %]
templates/webpages/shop_part/_filter.html
2 2
[%- USE L %]
3 3
[%- USE LxERP %]
4 4
[%- USE HTML %]
5
<!-- ShopOrder -->
6 5
<form action='controller.pl' method='post' id="shop_part_filter">
7 6
 <table id='filter_table'>
8 7

  
templates/webpages/shop_part/_list_articles.html
1 1
[%- USE HTML -%][%- USE LxERP -%][%- USE L -%][%- USE T8 -%]
2 2
[% USE Dumper %]
3
<!-- ShopPart -->
4
<!-- ShopPart -->
5
<!-- ShopPart -->
3

  
4

  
6 5
<h1>[% title %]</h1>
7 6
[%- PROCESS 'shop_part/_filter.html' filter=SELF.models.filtered.laundered %]
8 7
<hr>
templates/webpages/shop_part/_list_images.html
1
<!-- TMP -->
2 1
[%- USE HTML %][%- USE L -%][%- USE P -%][%- USE LxERP -%]
3 2
[%- USE T8 %][% USE Base64 %]
4 3
[%- USE Dumper %]
......
11 10
      <th>[% 'Description' | $T8 %]</th>
12 11
      <th>[% 'Filename' | $T8 %]</th>
13 12
      <th>[% 'Orig. Size w/h' | $T8 %]</th>
13
      <th>[% 'Action' | $T8 %]</th>
14 14
    </tr>
15 15
  </thead>
16 16
  <tbody>
......
18 18
    <tr class="listrow" id="image_id_[%  img.id %]">
19 19
      <td><img src="image/updown.png" alt="[%- LxERP.t8('reorder item') %]" class="dragdrop"></td>
20 20
      <td width="70px"><img src="data:[%  img.thumbnail_img_content_type %];base64,[%  img.thumbnail_img_content.encode_base64 %]" alt="[%  img.title %]"></td>
21
      <td>[%  HTML.escape(img.title) %]</td>
22
      <td>[%  HTML.escape(img.description) %]</td>
23
      <td>[%  HTML.escape(img.filename) %]</td>
24
      <td>[%  HTML.escape(img.thumbnail_img_width) _  ' x ' _ HTML.escape(img.thumbnail_img_height) %]</td>
21
      <td>[% HTML.escape(img.title) %]</td>
22
      <td>[% HTML.escape(img.description) %]</td>
23
      <td>[% HTML.escape(img.filename) %]</td>
24
      <td>[% HTML.escape(img.files_img_width) _  ' x ' _ HTML.escape(img.files_img_height) %]</td>
25
      <td>[% L.button_tag("kivi.FileUploader.delete_file(" _ img.id _ ", 'ShopPart/ajax_delete_file')", LxERP.t8('Delete'), confirm=LxERP.t8("Are you sure?")) %] [% L.button_tag("kivi.FileUploader.add_file(" _ img.id _ "," _ FORM.id _ ",'shop_part','ShopPart/ajax_update_file','jpg|png|tif|gif')", LxERP.t8('Edit')) %] </td>
25 26
    </tr>
26 27
   [%  END %]
27 28
  </tbody>
......
29 30

  
30 31
[% L.sortable_element('#images_list tbody', url=SELF.url_for(action='reorder'), with='image_id') %]
31 32
<p>
32
[% L.button_tag("add_file(this.form.id.value,'shop_part')", 'Fileupload') %]
33
[% L.button_tag("kivi.FileUploader.add_file(''," _ FORM.id _ ",'shop_part','ShopPart/ajax_upload_file','jpg|png|tif|gif')", LxERP.t8('Fileupload')) %]
33 34
</p>
34

  
35

  
36

  
37

  
38
<script type='text/javascript'>
39
<!--
40
function add_file(id,modul) {
41
  //var id = this.$('#part').val();
42
  kivi.popup_dialog({
43
        url :           'controller.pl?action=FileUploader/ajax_add_file',
44
        data:           'id=' + id + '&modul=' + modul,
45
        dialog:         { title: kivi.t8('File upload') }
46
  } );
47
   // var url = 'controller.pl?action=ShopPart/show_files?modul=shop_part&id=' + $('#id').val();
48
   // $('#images_list').load(url);
49
    //$('#jqueryui_popup_dialog').dialog('close');
50
  return true;
51
}
52
-->
53
</script>
templates/webpages/shop_part/_transfer_status.html
2 2
[%- USE Dumper -%]
3 3
[% SET data = job.data_as_hash %]
4 4

  
5
<!-- ShopOrder BGJ -->
6 5
<h2>[% LxERP.t8("Watch status") %]</h2>
7 6

  
8 7
[% L.hidden_tag('', job.id, id="smu_job_id") %]
templates/webpages/shop_part/_upload_status.html
3 3
[% SET data = job.data_as_hash %]
4 4

  
5 5

  
6
<!-- ShopPart BGJ -->
7 6
<h2>[% LxERP.t8("Watch status") %]</h2>
8 7

  
9 8
[% L.hidden_tag('', job.id, id="smu_job_id") %]
templates/webpages/shop_part/categories.html
4 4
[%- USE P -%]
5 5
[%- USE LxERP -%]
6 6
[%- USE Dumper -%]
7
<!-- ShopPart -->
7

  
8 8
[%  LxERP.t8("Part") %]: [% HTML.escape(SELF.shop_part.part.displayable_name) %]<br>
9 9
[%  LxERP.t8("Shop") %]: [% HTML.escape(SELF.shop_part.shop.description) %]
10 10
<br>
......
14 14

  
15 15
<form action="controller.pl" method="post">
16 16
  [% BLOCK recurse %]
17
  [% # path = '' %]<!-- TODO: Pfad wg neuer Kategorie im Shop anlegen -->
17
    [% # path = '' %]<!-- TODO: Pfad wg neuer Kategorie im Shop anlegen -->
18 18
    [% FOREACH obj = data %]
19 19
      <ul>
20 20
        <li>
21 21
        [% checked = '' %]
22 22
        [% # path = path _ obj.name %]
23 23
        [% # test = path.split('\|') %]
24
        [% # Dumper.dump_html(SELF.shop_part.shop_category.size) %]
24
        [% # Dumper.dump_html(SELF.shop_part.shop_category) %]
25 25
        [% IF SELF.shop_part.shop_category.1.grep(obj.name).size %]
26 26
          [% checked = 'checked' %]
27 27
        [% ELSE %]
......
31 31
            [% END %]
32 32
          [% END %]
33 33
        [% END %]
34
          [% L.checkbox_tag('categories[]',value=obj.id _"," _ obj.name _ ",PFAD", checked=checked) %][% HTML.escape(obj.name) %]</li>
34
          [% L.checkbox_tag('categories[]',value=obj.id, checked=checked) %][% HTML.escape(obj.name) %][% L.hidden_tag("cat_id_" _ obj.id, obj.name) %]</li>
35 35
        [% IF obj.childrenCount >= 1 %]
36 36
          [% # path = path _ '|' %]
37 37
          [% INCLUDE recurse data=obj.children %]
......
41 41
  [% END %]
42 42
  <div><h2>[% LxERP.t8("Shopcategories") %]</h2>
43 43
      [% FOREACH row = CATEGORIES %]
44
<!-- TODO: Is still hardcoded 'Root' is shopware specified -->
44 45
        [% IF row.name == 'Root' %]
45 46
          [% IF row.childrenCount >= 1 %]
46 47
            [% path = '' %]
templates/webpages/shop_part/edit.html
5 5
[%- USE LxERP -%]
6 6
[%- USE Dumper -%]
7 7

  
8
<!-- ShopPart -->
9
<!-- ShopPart -->
10 8
[% LxERP.t8("Part") %]: [% HTML.escape(SELF.shop_part.part.displayable_name) %]<br>
11 9
[% LxERP.t8("Shop") %]: [% HTML.escape(SELF.shop_part.shop.description) %]
12
[% Dumper.dump_html(SELF) %]
10
[% # Dumper.dump_html(SELF) %]
13 11
<form action="controller.pl" method="post">
14 12
  <div>
15 13
    [% IF SELF.shop_part.id %]
......
27 25
    </tr>
28 26
    <tr>
29 27
     <td>[% LxERP.t8("Active") %]</td>
30
     <td>[% L.yes_no_tag("shop_part.active", SELF.shop_part.active) %]</td>
28
     <td>[% L.yes_no_tag("shop_part.active", SELF.shop_part.active, default = "yes") %]</td>
31 29
    </tr>
32 30
    <tr>
33 31
      <th align="right">[% 'Price Source' | $T8 %]</th>
templates/webpages/shops/form.html
72 72
 </p>
73 73

  
74 74
 <hr>
75
 <table>
76
  <tr>
77
    <th align="right">[% 'Description' | $T8 %]</th>
78
    <th>Last update</th>
79
    <th>[% 'Available qty' | $T8 %]</th>
80
  </tr>
81
 [%- FOREACH shop_part = SELF.shop.updatable_parts %]
82
  <tr>
83
   <td>[% P.part(shop_part.part) %]</td>
84
   <td>[% shop_part.last_update.to_kivitendo %]</td>
85
   <td>[% shop_part.part.get_stock %]</td>
86
  </tr>
87
 [%- END %]
88
 </table>
89

  
75 90

  
76 91
<script type="text/javascript">
77 92
<!--

Auch abrufbar als: Unified diff