Auftrags-Controller: Benutzereinstellung: Positions-Update aus Artikel-Stamm
authorBernd Bleßmann <bernd@kivitendo-premium.de>
Tue, 1 Oct 2019 16:15:33 +0000 (18:15 +0200)
committerBernd Bleßmann <bernd@kivitendo-premium.de>
Tue, 1 Oct 2019 16:15:33 +0000 (18:15 +0200)
SL/AM.pm
SL/Controller/Order.pm
SL/Helper/UserPreferences/UpdatePositions.pm [new file with mode: 0644]
bin/mozilla/am.pl
locale/de/all
locale/en/all
templates/webpages/am/config.html
templates/webpages/order/tabs/_row.html
templates/webpages/order/tabs/basic_data.html

index 6302c24..0ba1ec8 100644 (file)
--- a/SL/AM.pm
+++ b/SL/AM.pm
@@ -54,6 +54,7 @@ use SL::DB;
 use SL::GenericTranslations;
 use SL::Helper::UserPreferences::PositionsScrollbar;
 use SL::Helper::UserPreferences::PartPickerSearch;
+use SL::Helper::UserPreferences::UpdatePositions;
 
 use strict;
 
@@ -541,6 +542,10 @@ sub sales_search_customer_partnumber {
   SL::Helper::UserPreferences::PartPickerSearch->new()->get_sales_search_customer_partnumber();
 }
 
+sub positions_show_update_button {
+  SL::Helper::UserPreferences::UpdatePositions->new()->get_show_update_button();
+}
+
 sub save_preferences {
   $main::lxdebug->enter_sub();
 
@@ -575,6 +580,9 @@ sub save_preferences {
   if (exists $form->{sales_search_customer_partnumber}) {
     SL::Helper::UserPreferences::PartPickerSearch->new()->store_sales_search_customer_partnumber($form->{sales_search_customer_partnumber})
   }
+  if (exists $form->{positions_show_update_button}) {
+    SL::Helper::UserPreferences::UpdatePositions->new()->store_show_update_button($form->{positions_show_update_button})
+  }
 
   $main::lxdebug->leave_sub();
 
index 9b4c1bf..00efeca 100644 (file)
@@ -26,6 +26,7 @@ use SL::Helper::CreatePDF qw(:all);
 use SL::Helper::PrintOptions;
 use SL::Helper::ShippedQty;
 use SL::Helper::UserPreferences::PositionsScrollbar;
+use SL::Helper::UserPreferences::UpdatePositions;
 
 use SL::Controller::Helper::GetModels;
 
@@ -40,7 +41,7 @@ use Sort::Naturally;
 use Rose::Object::MakeMethods::Generic
 (
  scalar => [ qw(item_ids_to_delete) ],
- 'scalar --get_set_init' => [ qw(order valid_types type cv p multi_items_models all_price_factors search_cvpartnumber) ],
+ 'scalar --get_set_init' => [ qw(order valid_types type cv p multi_items_models all_price_factors search_cvpartnumber show_update_button) ],
 );
 
 
@@ -795,6 +796,7 @@ sub action_add_item {
                                      TYPE                => $self->type,
                                      ALL_PRICE_FACTORS   => $self->all_price_factors,
                                      SEARCH_CVPARTNUMBER => $self->search_cvpartnumber,
+                                     SHOW_UPDATE_BUTTON  => $self->show_update_button,
   );
 
   $self->js
@@ -823,6 +825,7 @@ sub action_add_item {
                                          TYPE                => $self->type,
                                          ALL_PRICE_FACTORS   => $self->all_price_factors,
                                          SEARCH_CVPARTNUMBER => $self->search_cvpartnumber,
+                                         SHOW_UPDATE_BUTTON  => $self->show_update_button,
       );
       $self->js
         ->append('#row_table_id', $row_as_html);
@@ -906,6 +909,7 @@ sub action_add_multi_items {
                                        TYPE                => $self->type,
                                        ALL_PRICE_FACTORS   => $self->all_price_factors,
                                        SEARCH_CVPARTNUMBER => $self->search_cvpartnumber,
+                                       SHOW_UPDATE_BUTTON  => $self->show_update_button,
     );
 
     $self->js->append('#row_table_id', $row_as_html);
@@ -1208,6 +1212,12 @@ sub init_search_cvpartnumber {
   return $search_cvpartnumber;
 }
 
+sub init_show_update_button {
+  my ($self) = @_;
+
+  !!SL::Helper::UserPreferences::UpdatePositions->new()->get_show_update_button();
+}
+
 sub init_p {
   SL::Presenter->get;
 }
diff --git a/SL/Helper/UserPreferences/UpdatePositions.pm b/SL/Helper/UserPreferences/UpdatePositions.pm
new file mode 100644 (file)
index 0000000..ae06285
--- /dev/null
@@ -0,0 +1,68 @@
+package SL::Helper::UserPreferences::UpdatePositions;
+
+use strict;
+use parent qw(Rose::Object);
+
+use Carp;
+use List::MoreUtils qw(none);
+
+use SL::Helper::UserPreferences;
+
+use Rose::Object::MakeMethods::Generic (
+  'scalar --get_set_init' => [ qw(user_prefs) ],
+);
+
+sub get_show_update_button {
+  !!$_[0]->user_prefs->get('show_update_button');
+}
+
+sub store_show_update_button {
+  $_[0]->user_prefs->store('show_update_button', $_[1]);
+}
+
+sub init_user_prefs {
+  SL::Helper::UserPreferences->new(
+    namespace => $_[0]->namespace,
+  )
+}
+
+# read only stuff
+sub namespace     { 'UpdatePositions' }
+sub version       { 1 }
+
+1;
+
+__END__
+
+=pod
+
+=encoding utf-8
+
+=head1 NAME
+
+SL::Helper::UserPreferences::UpdatePositions - preferences intended
+to store user settings for displaying an update button for the postions
+of document forms to update the positions (parts) from master data.
+
+=head1 SYNOPSIS
+
+  use SL::Helper::UserPreferences::UpdatePositions;
+  my $prefs = SL::Helper::UserPreferences::UpdatePositions->new();
+
+  $prefs->store_show_update_button(1);
+  my $value = $prefs->get_show_update_button;
+
+=head1 DESCRIPTION
+
+This module manages storing the user's choise for displaying an update button
+in the positions area in forms (new order controller).
+
+=head1 BUGS
+
+None yet :)
+
+=head1 AUTHOR
+
+Bernd Bleßmann E<lt>bernd@kivitendo-premium.deE<gt>
+
+=cut
index f2987b6..e992ebe 100644 (file)
@@ -663,6 +663,7 @@ sub config {
   $form->{positions_scrollbar_height}       = AM->positions_scrollbar_height();
   $form->{purchase_search_makemodel}        = AM->purchase_search_makemodel();
   $form->{sales_search_customer_partnumber} = AM->sales_search_customer_partnumber();
+  $form->{positions_show_update_button}     = AM->positions_show_update_button();
 
   $myconfig{show_form_details} = 1 unless (defined($myconfig{show_form_details}));
   $form->{CAN_CHANGE_PASSWORD} = $main::auth->can_change_password();
index 949125b..6a49a3d 100755 (executable)
@@ -2959,6 +2959,7 @@ $self->{texts} = {
   'Show the picture in the part form' => 'Bild in Warenmaske anzeigen',
   'Show the pictures in the result for search parts' => 'Bilder in Suchergebnis für Stammdaten -> Berichte -> Waren anzeigen',
   'Show the weights of articles and the total weight in orders, invoices and delivery notes?' => 'Sollen Warengewichte und Gesamtgewicht in Aufträgen, Rechnungen und Lieferscheinen angezeigt werden?',
+  'Show update button for positions in order forms' => 'Aktualisieren-Knopf bei Positionen in Belegen anzeigen (neuer Auftrags-Controller)',
   'Show weights'                => 'Gewichte anzeigen',
   'Show your TODO list after logging in' => 'Aufgabenliste nach dem Anmelden anzeigen',
   'Show »not delivered qty/value« column in sales and purchase orders' => 'Spalte »Nicht gelieferte Menge/Wert« in Aufträgen anzeigen',
index bbd4098..e86688b 100644 (file)
@@ -2959,6 +2959,7 @@ $self->{texts} = {
   'Show the picture in the part form' => '',
   'Show the pictures in the result for search parts' => '',
   'Show the weights of articles and the total weight in orders, invoices and delivery notes?' => '',
+  'Show update button for positions in order forms' => '',
   'Show weights'                => '',
   'Show your TODO list after logging in' => '',
   'Show »not delivered qty/value« column in sales and purchase orders' => '',
index b8cef83..6e65c4d 100644 (file)
         [%- 'This also enables displaying a column with the customer partnumber (new order controller).' | $T8 %]
       </td>
      </tr>
+     <tr>
+      <th align="right">[% 'Show update button for positions in order forms' | $T8 %]</th>
+      <td>
+        [% L.yes_no_tag('positions_show_update_button', positions_show_update_button) %]
+      </td>
+     </tr>
      [%- END -%]
 
      <tr>
index 20755d2..42a7a77 100644 (file)
@@ -32,6 +32,7 @@
                        LxERP.t8("X"),
                        confirm=LxERP.t8("Are you sure?")) %]
     </td>
+    [%- IF SHOW_UPDATE_BUTTON -%]
     <td align="center">
       [%- L.img_tag(src="image/rotate_cw.svg",
                     alt=LxERP.t8('Update from master data'),
@@ -39,6 +40,7 @@
                     onclick="if (!confirm('" _ LxERP.t8("Are you sure to update this position from master data?") _ "')) return false; kivi.Order.update_row_from_master_data(this);",
                     id='update_from_master') %]
     </td>
+    [%- END -%]
     <td>
       <div name="partnumber">[% HTML.escape(ITEM.part.partnumber) %]</div>
     </td>
index 26aedd5..c040f11 100644 (file)
                 <th class="listheading" nowrap width="3" >[%- 'position'     | $T8 %] </th>
                 <th class="listheading" style='text-align:center' nowrap width="1"><img src="image/updown.png" alt="[%- LxERP.t8('reorder item') %]"></th>
                 <th class="listheading" style='text-align:center' nowrap width="1"><img src="image/close.png" alt="[%- LxERP.t8('delete item') %]"></th>
+                [%- IF SELF.show_update_button -%]
                 <th class="listheading" style='text-align:center' nowrap width="1">
                   [%- L.img_tag(src="image/rotate_cw.svg",
                                 alt=LxERP.t8('Update from master data'),
                                 onclick="if (!confirm('" _ LxERP.t8("Are you sure to update all positions from master data?") _ "')) return false; kivi.Order.update_all_rows_from_master_data();",
                                 id='update_from_master') %]
                 </th>
+                [%- END %]
                 <th id="partnumber_header_id"   class="listheading" nowrap width="15"><a href='#' onClick='javascript:kivi.Order.reorder_items("partnumber")'> [%- 'Partnumber'  | $T8 %]</a></th>
                 [%- IF SELF.search_cvpartnumber -%]
                 <th id="cvpartnumber_header_id" class="listheading" nowrap width="15"><a href='#' onClick='javascript:kivi.Order.reorder_items("cvpartnumber")' > [%- SELF.cv == "customer" ? LxERP.t8('Customer Part Number') : LxERP.t8('Model') %]</a></th>
             </thead>
 
             [%- FOREACH item = SELF.order.items_sorted %]
-              [%- PROCESS order/tabs/_row.html ITEM=item ID=(item.id||item.new_fake_id) TYPE=SELF.type ALL_PRICE_FACTORS=SELF.all_price_factors SEARCH_CVPARTNUMBER=SELF.search_cvpartnumber %]
+              [%- PROCESS order/tabs/_row.html
+                  ITEM=item
+                  ID=(item.id||item.new_fake_id)
+                  TYPE=SELF.type
+                  ALL_PRICE_FACTORS=SELF.all_price_factors
+                  SEARCH_CVPARTNUMBER=SELF.search_cvpartnumber
+                  SHOW_UPDATE_BUTTON=SELF.show_update_button
+              -%]
             [%- END %]
 
           </table>