use Clone qw(clone);
use SL::DB::Part;
use SL::DB::PartsGroup;
+use SL::DB::Shop;
use SL::Controller::Helper::GetModels;
use SL::Locale::String qw(t8);
use SL::JSON;
use Rose::Object::MakeMethods::Generic (
'scalar --get_set_init' => [ qw(parts models part p warehouses multi_items_models
- makemodels
+ makemodels shops_not_assigned
orphaned
assortment assortment_items assembly assembly_items
all_pricegroups all_translations all_partsgroups all_units
sub _set_javascript {
my ($self) = @_;
- $::request->layout->use_javascript("${_}.js") for qw(kivi.Part kivi.File kivi.PriceRule ckeditor/ckeditor ckeditor/adapters/jquery);
+ $::request->layout->use_javascript("${_}.js") for qw(kivi.Part kivi.File kivi.PriceRule ckeditor/ckeditor ckeditor/adapters/jquery kivi.ShopPart);
$::request->layout->add_javascripts_inline("\$(function(){kivi.PriceRule.load_price_rules_for_part(@{[ $self->part->id ]})});") if $self->part->id;
}
# used by edit, save, delete and add
if ( $::form->{part}{id} ) {
- return SL::DB::Part->new(id => $::form->{part}{id})->load(with => [ qw(makemodels prices translations partsgroup) ]);
+ return SL::DB::Part->new(id => $::form->{part}{id})->load(with => [ qw(makemodels prices translations partsgroup shop_parts shop_parts.shop) ]);
} else {
die "part_type missing" unless $::form->{part}{part_type};
return SL::DB::Part->new(part_type => $::form->{part}{part_type});
}
}
+sub init_shops_not_assigned {
+ my ($self) = @_;
+
+ my @used_shop_ids = map { $_->shop->id } @{ $self->part->shop_parts };
+ if ( @used_shop_ids ) {
+ return SL::DB::Manager::Shop->get_all( query => [ obsolete => 0, '!id' => \@used_shop_ids ], sort_by => 'sortkey' );
+ }
+ else {
+ return SL::DB::Manager::Shop->get_all( query => [ obsolete => 0 ], sort_by => 'sortkey' );
+ }
+}
+
sub init_all_units {
my ($self) = @_;
if ( $self->part->orphaned ) {
--- /dev/null
+[%- USE HTML %][%- USE L -%][%- USE P -%][%- USE LxERP -%]
+[%- USE Dumper %]
+[%- USE JavaScript -%]
+<div id="shop_variables">
+ <h2>[% LxERP.t8("Active shops:") %]</h2>
+ <table width="100%">
+ <thead>
+ <tr class="listheading">
+ <th>[% LxERP.t8("Shop") %]</th>
+ <th>[% LxERP.t8("Active") %]</th>
+ <th>[% LxERP.t8("Shop part") %]</th>
+ <th>[% LxERP.t8("Price source") %]</th>
+ <th>[% LxERP.t8("Price") %]</th>
+ <th>[% LxERP.t8("Stock Local/Shop") %]</th>
+ <th>[% LxERP.t8("Last update") %]</th>
+ <th>[% LxERP.t8("Action") %]</th>
+ <th>[% LxERP.t8("Action") %]</th>
+ <th>[% LxERP.t8("Action") %]</th>
+ </tr>
+ </thead>
+ [% # L.dump(SELF.part) %]
+ [%- FOREACH shop_part = SELF.part.shop_parts %]
+ [% IF !shop_part.shop.obsolete %]
+ <tr class="listrow">
+ <td>[% HTML.escape( shop_part.shop.description ) %]</td>
+ <td>[% L.html_tag('span', shop_part.active, id => 'shop_part_active_' _ shop_part.id ) %]</td>
+ <td>[% L.html_tag('span', shop_part.shop_description, id => 'shop_part_description_' _ shop_part.id ) %]</td>
+ <td>[% L.html_tag('span',LxERP.t8(), id => 'active_price_source_' _ shop_part.id) %] </td>
+ <td>[% L.html_tag('span','Price', id => 'price_' _ shop_part.id) %]</td>
+ <td>[% L.html_tag('span','Stock', id => 'stock_' _ shop_part.id) %]</td>
+ <td>[% L.html_tag('span', shop_part.last_update.to_kivitendo('precision' => 'minute'), id => 'shop_part_last_update_' _ shop_part.id ) %]</td>
+ <td>[% L.button_tag("kivi.ShopPart.edit_shop_part(" _ shop_part.id _ ")", LxERP.t8("Edit")) %]</td>
+ <td>[% L.button_tag("kivi.ShopPart.update_shop_part(" _ shop_part.id _ ")", LxERP.t8("Upload")) %]</td>
+ <td>[% L.button_tag("kivi.ShopPart.get_all_categories(" _ shop_part.id _ ")", LxERP.t8("Shopcategories")) %]<br>
+ [% IF shop_part.shop_category %]
+ [% IF shop_part.shop_category.1.size > 1%]
+ [% FOREACH cat = shop_part.shop_category %]
+ [% HTML.escape(cat.1) %]<br>
+ [% END %]
+ [% ELSE %]
+ [% HTML.escape(shop_part.shop_category.1) %]<br>
+ [% END %]
+ [% END %]
+ </td>
+ </tr>
+ <script type="text/javascript">
+ $(function() {
+ kivi.ShopPart.update_price_n_price_source([% shop_part.id %],'[% shop_part.active_price_source %]');
+ kivi.ShopPart.update_stock([% shop_part.id %]);
+ });
+ </script>
+ [% END %]
+ [%- END %]
+ [%- FOREACH shop = SELF.shops_not_assigned %]
+ <tr>
+ <td>[% HTML.escape( shop.description ) %]</td>
+ <td></td>
+ <td></td>
+ <td></td>
+ <td></td>
+ <td></td>
+ <td>[% L.button_tag("kivi.ShopPart.create_shop_part(" _ id _ ", " _ shop.id _ ")", LxERP.t8("Add")) %]</td>
+ </tr>
+ </thead>
+ [%- END %]
+</table>
+
+
+[% # L.dump(shop_part) %]
+<h2>[% LxERP.t8("Shopimages - valid for all shops") %]</h2>
+ [%- IF shop_part.part_id %]
+ <script type="text/javascript">
+ $(function() {
+ kivi.ShopPart.show_images([% shop_part.part_id %]);
+ });
+ </script>
+ <div id="shop_images" border=1 ></div>
+ [%- ELSE %]
+ <div id="shop_images" border=1 >[% LxERP.t8('To upload images: Please create shoppart first') %]</div>
+ [%- END %]
+</div>
+
[%- IF CUSTOM_VARIABLES.size %]
<li><a href="#custom_variables">[% 'Custom Variables' | $T8 %]</a></li>
[%- END %]
+ [% IF AUTH.assert('shop_part_edit', 1) && SELF.part.id && SELF.part.shop %]
+ <li><a href="#shop_variables">[% 'Shop variables' | $T8 %]</a></li>
+ [% END %]
</ul>
<div id="basic_data">
<div id="sales_price_information">
[% PROCESS part/_sales_price_information.html id=SELF.part.id %]
</div>
+ [% IF AUTH.assert('shop_part_edit', 1) && SELF.part.id %]
+ <div id="shop_variables">
+ [% PROCESS 'part/_shop.html' %]
+ </div>
+ [%- END %]
[%- END %]
[%- IF CUSTOM_VARIABLES.size %]