Revision 3c7d9283
Von Werner Hahn vor mehr als 7 Jahren hinzugefügt
SL/Controller/File.pm | ||
---|---|---|
file_type => $self->file_type );
|
||
}
|
||
$self->files(\@files);
|
||
$self->_mk_render('file/list',1,0,$json);
|
||
|
||
if($self->object_type eq 'shop_image'){
|
||
$self->js
|
||
->run('kivi.ShopPart.show_images',$self->object_id)
|
||
->render();
|
||
}else{
|
||
$self->_mk_render('file/list',1,0,$json);
|
||
}
|
||
}
|
||
|
||
sub _get_from_import {
|
SL/Controller/ShopPart.pm | ||
---|---|---|
$self->render('shop_part/_list_images', { header => 0 }, IMAGES => $images);
|
||
}
|
||
|
||
sub action_ajax_upload_file{
|
||
my ($self, %params) = @_;
|
||
|
||
my $attributes = $::form->{ $::form->{form_prefix} } || die "Missing attributes";
|
||
|
||
$attributes->{filename} = ((($::form->{ATTACHMENTS} || {})->{ $::form->{form_prefix} } || {})->{file_content} || {})->{filename};
|
||
|
||
my @errors;
|
||
my @file_errors = SL::DB::File->new(%{ $attributes })->validate;
|
||
push @errors,@file_errors if @file_errors;
|
||
|
||
my @type_error = SL::Controller::FileUploader->validate_filetype($attributes->{filename},$::form->{aft});
|
||
push @errors,@type_error if @type_error;
|
||
|
||
return $self->js->error(@errors)->render($self) if @errors;
|
||
|
||
$self->file->assign_attributes(%{ $attributes });
|
||
$self->file->file_update_type_and_dimensions;
|
||
$self->file->save;
|
||
|
||
$self->js
|
||
->dialog->close('#jqueryui_popup_dialog')
|
||
->run('kivi.ShopPart.show_images',$self->file->trans_id)
|
||
->render();
|
||
}
|
||
|
||
#sub action_ajax_update_file{
|
||
# my ($self, %params) = @_;
|
||
|
||
# my $attributes = $::form->{ $::form->{form_prefix} } || die "Missing attributes";
|
||
|
||
# if (!$attributes->{file_content}) {
|
||
# delete $attributes->{file_content};
|
||
# } else {
|
||
# $attributes->{filename} = ((($::form->{ATTACHMENTS} || {})->{ $::form->{form_prefix} } || {})->{file_content} || {})->{filename};
|
||
# }
|
||
|
||
# my @errors;
|
||
# my @type_error = SL::Controller::FileUploader->validate_filetype($attributes->{filename},$::form->{aft});
|
||
# push @errors,@type_error if @type_error;
|
||
# $self->file->assign_attributes(%{ $attributes });
|
||
# my @file_errors = $self->file->validate if $attributes->{file_content};;
|
||
# push @errors,@file_errors if @file_errors;
|
||
|
||
# return $self->js->error(@errors)->render($self) if @errors;
|
||
|
||
# $self->file->file_update_type_and_dimensions if $attributes->{file_content};
|
||
# $self->file->save;
|
||
|
||
# $self->js
|
||
# ->dialog->close('#jqueryui_popup_dialog')
|
||
# ->run('kivi.ShopPart.show_images',$self->file->trans_id)
|
||
# ->render();
|
||
#}
|
||
|
||
sub action_ajax_delete_file {
|
||
my ( $self ) = @_;
|
||
$self->file->delete;
|
||
... | ... | |
|
||
my ( $price, $price_src_str ) = $self->get_price_n_pricesource($self->shop_part->active_price_source);
|
||
|
||
#TODO Price must be formatted. $price_src_str must be translated
|
||
flash('info', $is_new ? t8('The shop part has been created.') : t8('The shop part has been saved.'));
|
||
$self->js->html('#shop_part_description_' . $self->shop_part->id, $self->shop_part->shop_description)
|
||
->html('#shop_part_active_' . $self->shop_part->id, $self->shop_part->active)
|
||
... | ... | |
->run(
|
||
'kivi.ShopPart.shop_part_dialog',
|
||
t8('Shop part'),
|
||
$self->render('shop_part/edit', { output => 0 }) #, shop_part => $self->shop_part)
|
||
$self->render('shop_part/edit', { output => 0 })
|
||
)
|
||
->reinit_widgets;
|
||
|
||
... | ... | |
my $articles = SL::DB::Manager::ShopPart->get_all(where => [ 'shop.obsolete' => 0 ],with_objects => [ 'part','shop' ], sort_by => $sort_by );
|
||
|
||
foreach my $article (@{ $articles}) {
|
||
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' );
|
||
my $images = SL::DB::Manager::ShopImage->get_all_count( where => [ 'files.object_id' => $article->part->id, ], with_objects => 'file', sort_by => 'position' );
|
||
$article->{images} = $images;
|
||
}
|
||
|
||
... | ... | |
|
||
require SL::DB::Pricegroup;
|
||
require SL::DB::Part;
|
||
#TODO Price must be formatted. Translations for $price_grp_str
|
||
my $price;
|
||
if ($price_src_str eq "master_data") {
|
||
my $part = SL::DB::Manager::Part->get_all( where => [id => $self->shop_part->part_id], with_objects => ['prices'],limit => 1)->[0];
|
||
... | ... | |
SL::DB::Manager::ShopPart->find_by(id => $::form->{shop_part_id});
|
||
} else {
|
||
SL::DB::ShopPart->new(shop_id => $::form->{shop_id}, part_id => $::form->{part_id});
|
||
#SL::DB::ShopPart->new;
|
||
};
|
||
}
|
||
|
||
... | ... | |
|
||
=back
|
||
|
||
=head1 TODO
|
||
|
||
Pricesrules, pricessources aren't fully implemented yet.
|
||
|
||
=head1 AUTHORS
|
||
|
||
G. Richardson E<lt>information@kivitendo-premium.deE<gt>
|
SL/ShopConnector/Shopware.pm | ||
---|---|---|
push ( @cat, $temp );
|
||
}
|
||
|
||
# my $images = SL::DB::Manager::File->get_all( where => [ modul => 'shop_part', trans_id => $part->{id} ]);
|
||
my $images = SL::DB::Manager::ShopImage->get_all( where => [ 'files.object_id' => $part->{id}, ], with_objects => 'file', sort_by => 'position' );
|
||
my @upload_img = ();
|
||
foreach my $img (@{ $images }) {
|
||
... | ... | |
my ($import,$data,$data_json);
|
||
# if( $shop_part->last_update){
|
||
my $partnumber = $::form->escape($part->{partnumber});#shopware don't accept / in articlenumber
|
||
# Shopware RestApi schreibt Fehleremail wenn Artikel nicht gefunden. es braucht aber irgendeine Abfrage, ob der Artikel schon im Shop ist.
|
||
# LWP->post = neuanlegen LWP->put = update
|
||
$data = $self->connector->get("http://$url/api/articles/$partnumber?useNumberAsId=true");
|
||
$data_json = $data->content;
|
||
$import = SL::JSON::decode_json($data_json);
|
||
... | ... | |
}
|
||
|
||
# get the right taxrate for the article
|
||
# TODO In extra Helper??
|
||
my $taxrate;
|
||
my $dbh = $::form->get_standard_dbh();
|
||
my $b_id = $part->buchungsgruppen_id;
|
||
... | ... | |
|
||
my $dataString = SL::JSON::to_json(\%shop_data);
|
||
$dataString = encode_utf8($dataString);
|
||
$main::lxdebug->dump(0, 'WH:UPLOAD ', $dataString);
|
||
my $upload_content;
|
||
my $upload;
|
||
if($import->{success}){
|
||
#update
|
||
my $partnumber = $::form->escape($part->{partnumber});#shopware don't accept / in articlenumber
|
||
my $upload = $self->connector->put("http://$url/api/articles/$partnumber?useNumberAsId=true",Content => $dataString);
|
||
$upload = $self->connector->put("http://$url/api/articles/$partnumber?useNumberAsId=true",Content => $dataString);
|
||
my $data_json = $upload->content;
|
||
$upload_content = SL::JSON::decode_json($data_json);
|
||
}else{
|
||
#upload
|
||
my $upload = $self->connector->post("http://$url/api/articles/",Content => $dataString);
|
||
$upload = $self->connector->post("http://$url/api/articles/",Content => $dataString);
|
||
my $data_json = $upload->content;
|
||
$upload_content = SL::JSON::decode_json($data_json);
|
||
}
|
||
# Don't know if this is needed
|
||
if(@upload_img) {
|
||
my $partnumber = $::form->escape($part->{partnumber});#shopware don't accept / in articlenumber
|
||
$self->connector->put("http://$url/api/generateArticleImages/$partnumber?useNumberAsId=true");
|
||
my $imgup = $self->connector->put("http://$url/api/generateArticleImages/$partnumber?useNumberAsId=true");
|
||
}
|
||
|
||
return $upload_content->{success};
|
||
}
|
||
|
js/kivi.ShopPart.js | ||
---|---|---|
},
|
||
id: 'files_upload',
|
||
dialog: { title: upload_title, width: 650, height: 240 } });
|
||
kivi.ShopPart.show_image(id);
|
||
return true;
|
||
}
|
||
|
Auch abrufbar als: Unified diff
shopmodul: Shoppart: Kommentare und nicht benötigte Zeilen raus