1 # This file has been auto-generated only because it didn't exist.
2 # Feel free to modify it at will; it will not be overwritten automatically.
4 package SL::DB::ShopPart;
9 use SL::DB::MetaSetup::ShopPart;
10 use SL::DB::Manager::ShopPart;
11 use SL::DB::Helper::AttrHTML;
12 #use SL::DB::Helper::ActsAsList;
14 __PACKAGE__->meta->initialize;
15 __PACKAGE__->attr_html('shop_description');
17 sub get_tax_and_price {
22 my ( $price_src_str, $price_src_id ) = split(/\//,$self->active_price_source);
25 if ($price_src_str eq "master_data") {
26 $part = SL::DB::Manager::Part->find_by( id => $self->part_id );
27 $price = $part->$price_src_id;
29 $part = SL::DB::Manager::Part->find_by( id => $self->part_id );
30 $price = $part->prices->[0]->price;
34 my $dbh = $::form->get_standard_dbh();
35 my $b_id = $part->buchungsgruppen_id;
36 my $t_id = $self->shop->taxzone_id;
38 my $sql_str = "SELECT a.rate AS taxrate from tax a
39 WHERE a.taxkey = (SELECT b.taxkey_id
40 FROM chart b LEFT JOIN taxzone_charts c ON b.id = c.income_accno_id
41 WHERE c.taxzone_id = $t_id
42 AND c.buchungsgruppen_id = $b_id)";
44 my $rate = selectall_hashref_query($::form, $dbh, $sql_str);
45 $taxrate = @$rate[0]->{taxrate}*100;
47 $tax_n_price->{price} = $price;
48 $tax_n_price->{tax} = $taxrate;
55 require SL::DB::ShopImage;
56 my $images = SL::DB::Manager::ShopImage->get_all( where => [ 'files.object_id' => $self->{part_id}, ], with_objects => 'file', sort_by => 'position' );
58 foreach my $img (@{ $images }) {
59 my $file = SL::File->get(id => $img->file->id );
60 my ($path, $extension) = (split /\./, $file->file_name);
61 my $content = File::Slurp::read_file($file->get_file);
62 my $temp ={ ( link => 'data:' . $file->mime_type . ';base64,' . MIME::Base64::encode($content, ""), #$content, # MIME::Base64::encode($content),
63 description => $img->file->title,
64 position => $img->position,
65 extension => $extension,
68 push( @upload_img, $temp);
83 SL::DB::ShopPart - Model for the 'shop_parts' table
87 This is a standard Rose::DB::Object based model and can be used as one.
93 =item C<get_tax_and_price>
95 Returns the price and the taxrate for an shop_article
99 Returns the images for the shop_article
105 Prices, pricesources, pricerules could be implemented
109 Werner Hahn E<lt>wh@futureworldsearch.netE<gt>