Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 75b1036d

Von Werner Hahn vor mehr als 6 Jahren hinzugefügt

  • ID 75b1036d62695266c3670a2dfd4370c2265549fb
  • Vorgänger d6de8b23
  • Nachfolger 50dba889

Shopmodul: ShopPart: Artikel hochladen und Anzeigen

Webshop:: ShopPart

Webshop:: ShopPart

WebShop: ShopPart - Formatierungen ShopPart
Meldung bei Bildern wenn der Artikel noch keinem Shop zugeordnet ist

Conflicts:
templates/webpages/ic/tabs/_shop.html

Webshop: ShopPart Backgroundjob Upload

Conflicts:
SL/BackgroundJob/ShopPartMassUpload.pm
SL/ShopConnector/Shopware.pm
menus/user/10-shopimport.yaml
templates/webpages/shop_part/_list_articles.html
templates/webpages/shop_part/_transfer_status.html
templates/webpages/shop_part/_upload_status.html

Webshop: ShopPart - Webpart Filter nach Anbauer und Shop Anfang

Conflicts:
SL/Controller/ShopPart.pm

Webshop: ShopPart Menu

Conflicts:
menus/user/10-shopimport.yaml

Webshop: ShopPart

Webshop: ShopPart - Mergefehler in templates/webpages/ic/tabs/_shop.html

Conflicts:
templates/webpages/ic/tabs/_shop.html

Webshop: ShopPart

Conflicts:
templates/webpages/shop_part/_filter.html

WebShop: ShopPart - Unterschiedliche Uploadmöglichkeiten (Alles, Nur Preis, Nur Bestand, Bestand und Preis)

Conflicts:
menus/user/10-shopimport.yaml

Conflicts:
SL/Controller/ShopPart.pm
SL/ShopConnector/Shopware.pm
templates/webpages/shop_part/_list_articles.html

WebShop: ShopPart - Shopartikelliste Aktiv grafik

Conflicts:
SL/Controller/ShopPart.pm
SL/ShopConnector/Shopware.pm
js/kivi.shop_part.js
t/background_job/known_jobs.t

Conflicts:
SL/Controller/ShopPart.pm
SL/DB/ShopPart.pm
templates/webpages/ic/tabs/_shop.html

Unterschiede anzeigen:

SL/Controller/ShopPart.pm
5 5

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

  
8
use SL::BackgroundJob::ShopPartMassUpload;
9
use SL::System::TaskServer;
8 10
use Data::Dumper;
9 11
use SL::Locale::String qw(t8);
10 12
use SL::DB::ShopPart;
......
12 14
use SL::Controller::FileUploader;
13 15
use SL::DB::Default;
14 16
use SL::Helper::Flash;
17
use MIME::Base64;
15 18

  
16 19
use Rose::Object::MakeMethods::Generic
17 20
(
18 21
   scalar                 => [ qw(price_sources) ],
19
  'scalar --get_set_init' => [ qw(shop_part file) ],
22
  'scalar --get_set_init' => [ qw(shop_part file shops producers) ],
20 23
);
21 24

  
22 25
__PACKAGE__->run_before('check_auth');
23
__PACKAGE__->run_before('add_javascripts', only => [ qw(edit_popup) ]);
26
__PACKAGE__->run_before('add_javascripts', only => [ qw(edit_popup list_articles) ]);
24 27
__PACKAGE__->run_before('load_pricesources',    only => [ qw(create_or_edit_popup) ]);
25 28

  
26 29
#
......
31 34
  my ($self) = @_;
32 35

  
33 36
  $self->render_shop_part_edit_dialog();
34
};
37
}
35 38

  
36 39
sub action_update_shop {
37 40
  my ($self, %params) = @_;
38 41

  
39 42
  my $shop_part = SL::DB::Manager::ShopPart->find_by(id => $::form->{shop_part_id});
40 43
  die unless $shop_part;
44

  
41 45
  require SL::Shop;
42 46
  my $shop = SL::Shop->new( config => $shop_part->shop );
43 47

  
44
  # data to upload to shop. Goes to SL::Connector::XXXConnector.
45 48
  my $part_hash = $shop_part->part->as_tree;
46 49
  my $json      = SL::JSON::to_json($part_hash);
47
  my $return    = $shop->connector->update_part($self->shop_part, $json);
50
  my $return    = $shop->connector->update_part($self->shop_part, $json,'all');
48 51

  
49 52
  # the connector deals with parsing/result verification, just needs to return success or failure
50 53
  if ( $return == 1 ) {
......
59 62
    $self->js->flash('error', t8('The shop part wasn\'t updated.'))->render;
60 63
  };
61 64

  
62
};
65
}
63 66

  
64 67
sub action_show_files {
65 68
  my ($self) = @_;
66 69

  
67
  require SL::DB::File;
68 70
  my $images = SL::DB::Manager::File->get_all_sorted( where => [ trans_id => $::form->{id}, modul => $::form->{modul}, file_content_type => { like => 'image/%' } ], sort_by => 'position' );
69 71

  
70 72
  $self->render('shop_part/_list_images', { header => 0 }, IMAGES => $images);
......
114 116
  my @file_errors = $self->file->validate if $attributes->{file_content};;
115 117
  push @errors,@file_errors if @file_errors;
116 118

  
117

  
118 119
  return $self->js->error(@errors)->render($self) if @errors;
119 120

  
120 121
  $self->file->file_update_type_and_dimensions if $attributes->{file_content};
......
153 154
  $self->js->render;
154 155
}
155 156

  
156
# old:
157
# sub action_edit {
158
#   my ($self) = @_;
159
#
160
#   $self->render('shop_part/edit'); #, { output => 0 }); #, price_source => $price_source)
161
# }
162
#
163
# used when saving existing ShopPart
164

  
165 157
sub action_update {
166 158
  my ($self) = @_;
167 159

  
......
173 165

  
174 166
  my ( $price, $price_src_str ) = $self->get_price_n_pricesource($::form->{pricesource});
175 167

  
176
  #TODO Price must be formatted. $price_src_str must be translated
177
  $self->js->html('#price_' . $self->shop_part->id, $price)
168
  $self->js->html('#price_' . $self->shop_part->id, $::form->format_amount(\%::myconfig,$price,2))
178 169
           ->html('#active_price_source_' . $self->shop_part->id, $price_src_str)
179 170
           ->render;
180 171
}
181 172

  
182 173
sub action_show_stock {
183 174
  my ($self) = @_;
184
  my ( $stock_local, $stock_onlineshop );
175
  my ( $stock_local, $stock_onlineshop, $active_online );
185 176

  
186 177
  require SL::Shop;
187 178
  my $shop = SL::Shop->new( config => $self->shop_part->shop );
188
  my $shop_article = $shop->connector->get_article($self->shop_part->part->partnumber);
179

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

  
190 186
  $stock_local = $self->shop_part->part->onhand;
191
  $stock_onlineshop = $shop_article->{data}->{mainDetail}->{inStock};
192 187

  
193
  $self->js->html('#stock_' . $self->shop_part->id, $stock_local."/".$stock_onlineshop)
188
  $self->js->html('#stock_' . $self->shop_part->id, $::form->format_amount(\%::myconfig,$stock_local,0)."/".$::form->format_amount(\%::myconfig,$stock_onlineshop,0))
189
           ->html('#toogle_' . $self->shop_part->id,$active_online)
194 190
           ->render;
195 191
}
196 192

  
193
sub action_get_n_write_categories {
194
  my ($self) = @_;
195

  
196
  my @shop_parts =  @{ $::form->{shop_parts_ids} || [] };
197
  foreach my $part(@shop_parts){
198

  
199
    my $shop_part = SL::DB::Manager::ShopPart->get_all( where => [id => $part], with_objects => ['part', 'shop'])->[0];
200
    require SL::DB::Shop;
201
    my $shop = SL::Shop->new( config => $shop_part->shop );
202
    my $online_article = $shop->connector->get_article($shop_part->part->partnumber);
203
    my $online_cat = $online_article->{data}->{categories};
204
    my @cat = ();
205
    for(keys %$online_cat){
206
    # The ShopwareConnector works with the CategoryID @categories[x][0] in others/new Connectors it must be tested
207
    # Each assigned categorie is saved with id,categorie_name an multidimensional array and could be expanded with categoriepath or what is needed
208
      my @cattmp;
209
      push( @cattmp,$online_cat->{$_}->{id} );
210
      push( @cattmp,$online_cat->{$_}->{name} );
211
      push( @cat,\@cattmp );
212
    }
213
    my $attributes->{shop_category} = \@cat;
214
    my $active->{active} = $online_article->{data}->{active};
215
    $shop_part->assign_attributes(%{$attributes}, %{$active});
216
    $shop_part->save;
217
  }
218
  $self->redirect_to( action => 'list_articles' );
219
}
197 220

  
198 221
sub create_or_update {
199 222
  my ($self) = @_;
......
214 237
  # $self->js->val('#partnumber', 'ladida');
215 238
  $self->js->html('#shop_part_description_' . $self->shop_part->id, $self->shop_part->shop_description)
216 239
           ->html('#shop_part_active_' . $self->shop_part->id, $self->shop_part->active)
217
           ->html('#price_' . $self->shop_part->id, $price)
240
           ->html('#price_' . $self->shop_part->id, $::form->format_amount(\%::myconfig,$price,2))
218 241
           ->html('#active_price_source_' . $self->shop_part->id, $price_src_str)
219 242
           ->run('kivi.shop_part.close_dialog')
220 243
           ->flash('info', t8("Updated shop part"))
......
241 264
  my ($self) = @_;
242 265

  
243 266
  my @categories =  @{ $::form->{categories} || [] };
244
  $main::lxdebug->dump(0, 'WH: KATEGORIEN: ', \@categories);
245
  my @cat = ();
246
  foreach my $cat ( @categories) {
247
    # TODO das koma macht Probleme z.B kategorie "Feldsalat, Rapunzel"
248
    my @temp = [split(/,/,$cat)];
249
    push( @cat, @temp );
250
  }
251
  $main::lxdebug->dump(0, 'WH: KAT2:',\@cat);
267

  
268
    # The ShopwareConnector works with the CategoryID @categories[x][0] in others/new Connectors it must be tested
269
    # Each assigned categorie is saved with id,categorie_name an multidimensional array and could be expanded with categoriepath or what is needed
270
    my @cat = ();
271
    foreach my $cat ( @categories) {
272
      my @cattmp;
273
      push( @cattmp,$cat );
274
      push( @cattmp,$::form->{"cat_id_${cat}"} );
275
      push( @cat,\@cattmp );
276
    }
252 277

  
253 278
  my $categories->{shop_category} = \@cat;
254 279

  
......
268 293

  
269 294
sub action_reorder {
270 295
  my ($self) = @_;
271
$main::lxdebug->message(0, "WH:REORDER ");
296

  
272 297
  require SL::DB::File;
273 298
  SL::DB::File->reorder_list(@{ $::form->{image_id} || [] });
274
  $main::lxdebug->message(0, "WH:REORDER II ");
275 299

  
276 300
  $self->render(\'', { type => 'json' });
277 301
}
278 302

  
303
sub action_list_articles {
304
  my ($self) = @_;
305

  
306
  my %filter = ($::form->{filter} ? parse_filter($::form->{filter}) : query => [ transferred => 0 ]);
307
  my $transferred = $::form->{filter}->{transferred_eq_ignore_empty} ne '' ? $::form->{filter}->{transferred_eq_ignore_empty} : '';
308
  my $sort_by = $::form->{sort_by} ? $::form->{sort_by} : 'part.partnumber';
309
  $sort_by .=$::form->{sort_dir} ? ' DESC' : ' ASC';
310
$main::lxdebug->message(0, "WH:LA ");
311

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

  
314
  foreach my $article (@{ $articles}) {
315
    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
    $article->{images} = $images;
317
  }
318
  $main::lxdebug->dump(0, 'WH:ARTIKEL ',\$articles);
319

  
320
  $self->render('shop_part/_list_articles', title => t8('Webshops articles'), SHOP_PARTS => $articles);
321
}
322

  
323
sub action_upload_status {
324
  my ($self) = @_;
325
  my $job     = SL::DB::BackgroundJob->new(id => $::form->{job_id})->load;
326
  my $html    = $self->render('shop_part/_upload_status', { output => 0 }, job => $job);
327

  
328
  $self->js->html('#status_mass_upload', $html);
329
  $self->js->run('kivi.shop_part.massUploadFinished') if $job->data_as_hash->{status} == SL::BackgroundJob::ShopPartMassUpload->DONE();
330
  $self->js->render;
331
}
332

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

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

  
339
  my $job                   = SL::DB::BackgroundJob->new(
340
    type                    => 'once',
341
    active                  => 1,
342
    package_name            => 'ShopPartMassUpload',
343
  )->set_data(
344
     shop_part_record_ids         => [ @shop_parts ],
345
     todo                         => $::form->{upload_todo},
346
     status                       => SL::BackgroundJob::ShopPartMassUpload->WAITING_FOR_EXECUTION(),
347
     conversation_errors          => [ ],
348
   )->update_next_run_at;
349
$main::lxdebug->dump(0, 'WH:MA JOB ',\$job);
350

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

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

  
356
   $self->js
357
      ->html('#status_mass_upload', $html)
358
      ->run('kivi.shop_part.massUploadStarted')
359
      ->render;
360
}
361

  
279 362
#
280 363
# internal stuff
281 364
#
......
338 421
  };
339 422
}
340 423

  
424
sub init_file {
425
  $main::lxdebug->message(0, "WH:INIT_FILES ");
426
  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
  return $file;
430
}
431

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

  
436
  require SL::DB::Shop;
437
  my @shops_dd = [ { title => t8("all") ,   value =>'' } ];
438
  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;
442

  
443
}
444

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

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

  
452
}
453

  
341 454
1;
342 455

  
343 456
__END__
......
361 474

  
362 475
=item C<action_update_shop>
363 476

  
364
  To be called from the "Update" button, for manually syncing a part with its shop. Generates a  Calls some ClientJS functions to modifiy original page.
477
  To be called from the "Update" button of the shoppart, for manually syncing/upload one part with its shop. Generates a  Calls some ClientJS functions to modifiy original page.
478

  
479
=item C<action_get_n_write_categories>
365 480

  
481
  Can be used to sync the categories of a shoppart with the categories from online.
366 482

  
367 483
=head1 AUTHORS
368 484

  
......
370 486
  W. Hahn E<lt>wh@futureworldsearch.netE<gt>
371 487

  
372 488
=cut
373

  
374
=cut
375
1;

Auch abrufbar als: Unified diff