Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision e0e75548

Von Werner Hahn vor mehr als 7 Jahren hinzugefügt

  • ID e0e75548260827661474c54bf88c0ae74799c0b6
  • Vorgänger de1e3e16
  • Nachfolger be60b289

WebshopApi: Shop-Tab in Partcontroller eingebaut

Unterschiede anzeigen:

SL/Controller/Part.pm
6 6
use Clone qw(clone);
7 7
use SL::DB::Part;
8 8
use SL::DB::PartsGroup;
9
use SL::DB::Shop;
9 10
use SL::Controller::Helper::GetModels;
10 11
use SL::Locale::String qw(t8);
11 12
use SL::JSON;
......
21 22

  
22 23
use Rose::Object::MakeMethods::Generic (
23 24
  'scalar --get_set_init' => [ qw(parts models part p warehouses multi_items_models
24
                                  makemodels
25
                                  makemodels shops_not_assigned
25 26
                                  orphaned
26 27
                                  assortment assortment_items assembly assembly_items
27 28
                                  all_pricegroups all_translations all_partsgroups all_units
......
636 637

  
637 638
sub _set_javascript {
638 639
  my ($self) = @_;
639
  $::request->layout->use_javascript("${_}.js")  for qw(kivi.Part kivi.File kivi.PriceRule ckeditor/ckeditor ckeditor/adapters/jquery);
640
  $::request->layout->use_javascript("${_}.js")  for qw(kivi.Part kivi.File kivi.PriceRule ckeditor/ckeditor ckeditor/adapters/jquery kivi.ShopPart);
640 641
  $::request->layout->add_javascripts_inline("\$(function(){kivi.PriceRule.load_price_rules_for_part(@{[ $self->part->id ]})});") if $self->part->id;
641 642
}
642 643

  
......
803 804
  # used by edit, save, delete and add
804 805

  
805 806
  if ( $::form->{part}{id} ) {
806
    return SL::DB::Part->new(id => $::form->{part}{id})->load(with => [ qw(makemodels prices translations partsgroup) ]);
807
    return SL::DB::Part->new(id => $::form->{part}{id})->load(with => [ qw(makemodels prices translations partsgroup shop_parts shop_parts.shop) ]);
807 808
  } else {
808 809
    die "part_type missing" unless $::form->{part}{part_type};
809 810
    return SL::DB::Part->new(part_type => $::form->{part}{part_type});
......
924 925
  }
925 926
}
926 927

  
928
sub init_shops_not_assigned {
929
  my ($self) = @_;
930

  
931
  my @used_shop_ids = map { $_->shop->id } @{ $self->part->shop_parts };
932
  if ( @used_shop_ids ) {
933
    return SL::DB::Manager::Shop->get_all( query => [ obsolete => 0, '!id' => \@used_shop_ids ], sort_by => 'sortkey' );
934
  }
935
  else {
936
    return SL::DB::Manager::Shop->get_all( query => [ obsolete => 0 ], sort_by => 'sortkey' );
937
  }
938
}
939

  
927 940
sub init_all_units {
928 941
  my ($self) = @_;
929 942
  if ( $self->part->orphaned ) {
templates/webpages/part/_shop.html
1
[%- USE HTML %][%- USE L -%][%- USE P -%][%- USE LxERP -%]
2
[%- USE Dumper %]
3
[%- USE JavaScript -%]
4
<div id="shop_variables">
5
 <h2>[% LxERP.t8("Active shops:") %]</h2>
6
 <table width="100%">
7
  <thead>
8
  <tr class="listheading">
9
   <th>[% LxERP.t8("Shop") %]</th>
10
   <th>[% LxERP.t8("Active") %]</th>
11
   <th>[% LxERP.t8("Shop part") %]</th>
12
   <th>[% LxERP.t8("Price source") %]</th>
13
   <th>[% LxERP.t8("Price") %]</th>
14
   <th>[% LxERP.t8("Stock Local/Shop") %]</th>
15
   <th>[% LxERP.t8("Last update") %]</th>
16
   <th>[% LxERP.t8("Action") %]</th>
17
   <th>[% LxERP.t8("Action") %]</th>
18
   <th>[% LxERP.t8("Action") %]</th>
19
  </tr>
20
  </thead>
21
  [% # L.dump(SELF.part) %]
22
  [%- FOREACH shop_part = SELF.part.shop_parts %]
23
  [% IF !shop_part.shop.obsolete %]
24
  <tr class="listrow">
25
   <td>[% HTML.escape( shop_part.shop.description ) %]</td>
26
   <td>[% L.html_tag('span', shop_part.active, id => 'shop_part_active_' _ shop_part.id ) %]</td>
27
   <td>[% L.html_tag('span', shop_part.shop_description, id => 'shop_part_description_' _ shop_part.id ) %]</td>
28
   <td>[% L.html_tag('span',LxERP.t8(), id => 'active_price_source_' _ shop_part.id) %] </td>
29
   <td>[% L.html_tag('span','Price', id => 'price_' _ shop_part.id) %]</td>
30
   <td>[% L.html_tag('span','Stock', id => 'stock_' _ shop_part.id) %]</td>
31
   <td>[% L.html_tag('span', shop_part.last_update.to_kivitendo('precision' => 'minute'), id => 'shop_part_last_update_' _ shop_part.id ) %]</td>
32
   <td>[% L.button_tag("kivi.ShopPart.edit_shop_part(" _ shop_part.id _ ")", LxERP.t8("Edit"))  %]</td>
33
   <td>[% L.button_tag("kivi.ShopPart.update_shop_part(" _ shop_part.id _ ")", LxERP.t8("Upload"))  %]</td>
34
   <td>[% L.button_tag("kivi.ShopPart.get_all_categories(" _ shop_part.id _ ")", LxERP.t8("Shopcategories"))  %]<br>
35
    [% IF shop_part.shop_category %]
36
      [% IF shop_part.shop_category.1.size > 1%]
37
        [% FOREACH cat = shop_part.shop_category %]
38
          [% HTML.escape(cat.1) %]<br>
39
        [% END %]
40
      [% ELSE %]
41
        [% HTML.escape(shop_part.shop_category.1) %]<br>
42
      [% END %]
43
    [% END %]
44
   </td>
45
  </tr>
46
  <script type="text/javascript">
47
    $(function() {
48
      kivi.ShopPart.update_price_n_price_source([% shop_part.id %],'[% shop_part.active_price_source %]');
49
      kivi.ShopPart.update_stock([% shop_part.id %]);
50
    });
51
  </script>
52
  [% END %]
53
  [%- END %]
54
  [%- FOREACH shop = SELF.shops_not_assigned %]
55
  <tr>
56
   <td>[% HTML.escape( shop.description ) %]</td>
57
   <td></td>
58
   <td></td>
59
   <td></td>
60
   <td></td>
61
   <td></td>
62
   <td>[% L.button_tag("kivi.ShopPart.create_shop_part(" _ id _ ", " _ shop.id _ ")", LxERP.t8("Add"))  %]</td>
63
  </tr>
64
  </thead>
65
  [%- END %]
66
</table>
67

  
68

  
69
[% # L.dump(shop_part) %]
70
<h2>[% LxERP.t8("Shopimages - valid for all shops") %]</h2>
71
  [%- IF shop_part.part_id %]
72
    <script type="text/javascript">
73
      $(function() {
74
        kivi.ShopPart.show_images([% shop_part.part_id %]);
75
      });
76
    </script>
77
    <div id="shop_images" border=1 ></div>
78
  [%- ELSE %]
79
    <div id="shop_images" border=1 >[% LxERP.t8('To upload images: Please create shoppart first') %]</div>
80
  [%- END %]
81
</div>
82

  
templates/webpages/part/form.html
41 41
    [%- IF CUSTOM_VARIABLES.size %]
42 42
    <li><a href="#custom_variables">[% 'Custom Variables' | $T8 %]</a></li>
43 43
    [%- END %]
44
    [% IF AUTH.assert('shop_part_edit', 1) && SELF.part.id && SELF.part.shop %]
45
    <li><a href="#shop_variables">[% 'Shop variables' | $T8 %]</a></li>
46
    [% END %]
44 47
   </ul>
45 48

  
46 49
   <div id="basic_data">
......
67 70
   <div id="sales_price_information">
68 71
     [% PROCESS part/_sales_price_information.html id=SELF.part.id %]
69 72
   </div>
73
   [% IF AUTH.assert('shop_part_edit', 1) && SELF.part.id %]
74
   <div id="shop_variables">
75
     [% PROCESS 'part/_shop.html' %]
76
   </div>
77
   [%- END %]
70 78
   [%- END %]
71 79

  
72 80
   [%- IF CUSTOM_VARIABLES.size %]

Auch abrufbar als: Unified diff