Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 23b2cbd7

Von Werner Hahn vor etwa 7 Jahren hinzugefügt

  • ID 23b2cbd78283e87f2171e6f6842cba3a46e0bd99
  • Vorgänger c9238eef
  • Nachfolger 60a0462f

shopmodul: Shoppart: Kommentare und nicht benötigte Zeilen raus

Unterschiede anzeigen:

SL/Controller/File.pm
289 289
  my ($id,$version) = split /_/, $::form->{id};
290 290
  my $file = SL::File->get(id => $id );
291 291
  $file->version($version) if $version;
292
  my $ref  = $file->get_content;
293
                                     );
294
          unlink($sfile->file_name);
295
        }
296
        1;
297
      } or do {
298
        $self->js->flash(       'error', t8('internal error (see details)'))
299
                 ->flash_detail('error', $@)->render;
300
        return;
301
      }
302
    }
303
  }
304
  $self->existing(\@existing);
305
  $self->_do_list(1);
306
}
307

  
308
sub action_download {
309
  my ($self) = @_;
310
  my ($id, $version) = split /_/, $::form->{id};
311
  my $file = SL::File->get(id => $id );
312
  $file->version($version) if $version;
313 292
  my $ref  = $file->get_content;
314 293
  if ( $file && $ref ) {
315 294
    return $self->send_file($ref,
......
400 379
                                );
401 380
  }
402 381
  $self->files(\@files);
403
  $self->_mk_render('file/list', 1, 0, $json);
382

  
383
  if($self->object_type eq 'shop_image'){
384
    $self->js
385
      ->run('kivi.ShopPart.show_images', $self->object_id)
386
      ->render();
387
  }else{
388
    $self->_mk_render('file/list', 1, 0, $json);
389
  }
404 390
}
405 391

  
406 392
sub _get_from_import {
SL/Controller/ShopPart.pm
71 71
  $self->render('shop_part/_list_images', { header => 0 }, IMAGES => $images);
72 72
}
73 73

  
74
sub action_ajax_upload_file{
75
  my ($self, %params) = @_;
76

  
77
  my $attributes                   = $::form->{ $::form->{form_prefix} } || die "Missing attributes";
78

  
79
  $attributes->{filename} = ((($::form->{ATTACHMENTS} || {})->{ $::form->{form_prefix} } || {})->{file_content} || {})->{filename};
80

  
81
  my @errors;
82
  my @file_errors = SL::DB::File->new(%{ $attributes })->validate;
83
  push @errors,@file_errors if @file_errors;
84

  
85
  my @type_error = SL::Controller::FileUploader->validate_filetype($attributes->{filename},$::form->{aft});
86
  push @errors,@type_error if @type_error;
87

  
88
  return $self->js->error(@errors)->render($self) if @errors;
89

  
90
  $self->file->assign_attributes(%{ $attributes });
91
  $self->file->file_update_type_and_dimensions;
92
  $self->file->save;
93

  
94
  $self->js
95
    ->dialog->close('#jqueryui_popup_dialog')
96
    ->run('kivi.ShopPart.show_images',$self->file->trans_id)
97
    ->render();
98
}
99

  
100
#sub action_ajax_update_file{
101
# my ($self, %params) = @_;
102

  
103
# my $attributes                   = $::form->{ $::form->{form_prefix} } || die "Missing attributes";
104

  
105
# if (!$attributes->{file_content}) {
106
#   delete $attributes->{file_content};
107
# } else {
108
#   $attributes->{filename} = ((($::form->{ATTACHMENTS} || {})->{ $::form->{form_prefix} } || {})->{file_content} || {})->{filename};
109
# }
110

  
111
# my @errors;
112
# my @type_error = SL::Controller::FileUploader->validate_filetype($attributes->{filename},$::form->{aft});
113
# push @errors,@type_error if @type_error;
114
# $self->file->assign_attributes(%{ $attributes });
115
# my @file_errors = $self->file->validate if $attributes->{file_content};;
116
# push @errors,@file_errors if @file_errors;
117

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

  
120
# $self->file->file_update_type_and_dimensions if $attributes->{file_content};
121
# $self->file->save;
122

  
123
# $self->js
124
#   ->dialog->close('#jqueryui_popup_dialog')
125
#   ->run('kivi.ShopPart.show_images',$self->file->trans_id)
126
#   ->render();
127
#}
128

  
129 74
sub action_ajax_delete_file {
130 75
  my ( $self ) = @_;
131 76
  $self->file->delete;
......
232 177

  
233 178
  my ( $price, $price_src_str ) = $self->get_price_n_pricesource($self->shop_part->active_price_source);
234 179

  
235
  #TODO Price must be formatted. $price_src_str must be translated
236 180
  flash('info', $is_new ? t8('The shop part has been created.') : t8('The shop part has been saved.'));
237 181
  $self->js->html('#shop_part_description_' . $self->shop_part->id, $self->shop_part->shop_description)
238 182
           ->html('#shop_part_active_' . $self->shop_part->id, $self->shop_part->active)
......
252 196
    ->run(
253 197
      'kivi.ShopPart.shop_part_dialog',
254 198
      t8('Shop part'),
255
      $self->render('shop_part/edit', { output => 0 }) #, shop_part => $self->shop_part)
199
      $self->render('shop_part/edit', { output => 0 })
256 200
    )
257 201
    ->reinit_widgets;
258 202

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

  
311 255
  foreach my $article (@{ $articles}) {
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' );
256
    my $images = SL::DB::Manager::ShopImage->get_all_count( where => [ 'files.object_id' => $article->part->id, ], with_objects => 'file', sort_by => 'position' );
313 257
    $article->{images} = $images;
314 258
  }
315 259

  
......
385 329

  
386 330
  require SL::DB::Pricegroup;
387 331
  require SL::DB::Part;
388
  #TODO Price must be formatted. Translations for $price_grp_str
389 332
  my $price;
390 333
  if ($price_src_str eq "master_data") {
391 334
    my $part       = SL::DB::Manager::Part->get_all( where => [id => $self->shop_part->part_id], with_objects => ['prices'],limit => 1)->[0];
......
410 353
    SL::DB::Manager::ShopPart->find_by(id => $::form->{shop_part_id});
411 354
  } else {
412 355
    SL::DB::ShopPart->new(shop_id => $::form->{shop_id}, part_id => $::form->{part_id});
413
    #SL::DB::ShopPart->new;
414 356
  };
415 357
}
416 358

  
......
466 408

  
467 409
=back
468 410

  
411
=head1 TODO
412

  
413
  Pricesrules, pricessources aren't fully implemented yet.
414

  
469 415
=head1 AUTHORS
470 416

  
471 417
  G. Richardson E<lt>information@kivitendo-premium.deE<gt>
SL/ShopConnector/Shopware.pm
250 250
    push ( @cat, $temp );
251 251
  }
252 252

  
253
  # my $images = SL::DB::Manager::File->get_all( where => [ modul => 'shop_part', trans_id => $part->{id} ]);
254 253
  my $images = SL::DB::Manager::ShopImage->get_all( where => [ 'files.object_id' => $part->{id}, ], with_objects => 'file', sort_by => 'position' );
255 254
  my @upload_img = ();
256 255
  foreach my $img (@{ $images }) {
......
270 269
  my ($import,$data,$data_json);
271 270
#  if( $shop_part->last_update){
272 271
    my $partnumber = $::form->escape($part->{partnumber});#shopware don't accept / in articlenumber
272
# Shopware RestApi schreibt Fehleremail wenn Artikel nicht gefunden. es braucht aber irgendeine Abfrage, ob der Artikel schon im Shop ist.
273
# LWP->post = neuanlegen LWP->put = update
273 274
    $data = $self->connector->get("http://$url/api/articles/$partnumber?useNumberAsId=true");
274 275
    $data_json = $data->content;
275 276
    $import = SL::JSON::decode_json($data_json);
......
288 289
  }
289 290

  
290 291
  # get the right taxrate for the article
292
  # TODO In extra Helper??
291 293
  my $taxrate;
292 294
  my $dbh = $::form->get_standard_dbh();
293 295
  my $b_id = $part->buchungsgruppen_id;
......
361 363

  
362 364
  my $dataString = SL::JSON::to_json(\%shop_data);
363 365
  $dataString = encode_utf8($dataString);
364
  $main::lxdebug->dump(0, 'WH:UPLOAD ', $dataString);
365 366
  my $upload_content;
367
  my $upload;
366 368
  if($import->{success}){
367 369
    #update
368 370
    my $partnumber = $::form->escape($part->{partnumber});#shopware don't accept / in articlenumber
369
    my $upload = $self->connector->put("http://$url/api/articles/$partnumber?useNumberAsId=true",Content => $dataString);
371
    $upload = $self->connector->put("http://$url/api/articles/$partnumber?useNumberAsId=true",Content => $dataString);
370 372
    my $data_json = $upload->content;
371 373
    $upload_content = SL::JSON::decode_json($data_json);
372 374
  }else{
373 375
    #upload
374
    my $upload = $self->connector->post("http://$url/api/articles/",Content => $dataString);
376
    $upload = $self->connector->post("http://$url/api/articles/",Content => $dataString);
375 377
    my $data_json = $upload->content;
376 378
    $upload_content = SL::JSON::decode_json($data_json);
377 379
  }
378 380
  # Don't know if this is needed
379 381
  if(@upload_img) {
380 382
    my $partnumber = $::form->escape($part->{partnumber});#shopware don't accept / in articlenumber
381
    $self->connector->put("http://$url/api/generateArticleImages/$partnumber?useNumberAsId=true");
383
    my $imgup = $self->connector->put("http://$url/api/generateArticleImages/$partnumber?useNumberAsId=true");
382 384
  }
385

  
383 386
  return $upload_content->{success};
384 387
}
385 388

  
js/kivi.ShopPart.js
154 154
                                 },
155 155
                        id:     'files_upload',
156 156
                        dialog: { title: upload_title, width: 650, height: 240 } });
157
    kivi.ShopPart.show_image(id);
158 157
    return true;
159 158
  }
160 159

  

Auch abrufbar als: Unified diff