]> wagnertech.de Git - mfinanz.git/blobdiff - SL/Controller/PartsPriceUpdate.pm
restart apache2 in postinst
[mfinanz.git] / SL / Controller / PartsPriceUpdate.pm
index 6d131f10e256465bbfeaec0e77e73f0f3e5f57da..738f29693c7d10a60a7c4aa50989ec7644b41b94 100644 (file)
@@ -21,6 +21,7 @@ __PACKAGE__->run_before('check_rights');
 sub action_search_update_prices {
   my ($self) = @_;
 
+  $self->setup_search_update_prices_action_bar;
   $self->render('ic/search_update_prices',
     title => t8('Update Prices'),
   );
@@ -62,8 +63,9 @@ sub action_confirm_price_update {
     return $self->action_search_update_prices;
   } else {
 
-    my $key = $::auth->create_unique_sesion_value(SL::JSON::to_json($self->filter));
+    my $key = $::auth->create_unique_session_value(SL::JSON::to_json($self->filter));
 
+    $self->setup_confirm_price_update_action_bar;
     $self->render('ic/confirm_price_update',
       num_matches => $num_matches,
       filter_key  => $key,
@@ -90,7 +92,7 @@ sub _create_filter_for_priceupdate {
   my @where_values;
   my $where = '1 = 1';
 
-  for my $item (qw(partnumber drawing microfiche make model pg.partsgroup description serialnumber)) {
+  for my $item (qw(partnumber drawing microfiche pg.partsgroup description serialnumber)) {
     my $column = $item;
     $column =~ s/.*\.//;
     next unless $filter->{$column};
@@ -128,10 +130,14 @@ sub _create_filter_for_priceupdate {
 
   }
 
-  for my $column (qw(make model)) {
-    next unless ($filter->{$column});
-    $where .= qq| AND p.id IN (SELECT DISTINCT parts_id FROM makemodel WHERE $column ILIKE ?|;
-    push @where_values, "%$filter->{$column}%";
+  if ($filter->{make}) {
+    $where .= qq| AND p.id IN (SELECT DISTINCT parts_id FROM makemodel WHERE make = ?) |;
+    push @where_values, $filter->{make};
+  }
+
+  if ($filter->{model}) {
+    $where .= qq| AND p.id IN (SELECT DISTINCT parts_id FROM makemodel WHERE model ILIKE ?) |;
+    push @where_values, "%$filter->{model}%";
   }
 
   return ($where, @where_values);
@@ -271,11 +277,44 @@ sub init_pricegroups_by_id {
 }
 
 sub check_rights {
-  $::auth->assert('part_service_assembly_edit');
+  $::auth->assert('part_service_assembly_edit & part_service_assembly_edit_prices');
 }
 
 sub init_filter {
   $::form->{filter} || {};
 }
 
+sub setup_search_update_prices_action_bar {
+  my ($self, %params) = @_;
+
+  for my $bar ($::request->layout->get('actionbar')) {
+    $bar->add(
+      action => [
+        t8('Continue'),
+        submit    => [ '#form', { action => 'PartsPriceUpdate/confirm_price_update' } ],
+        accesskey => 'enter',
+      ],
+    );
+  }
+}
+
+sub setup_confirm_price_update_action_bar {
+  my ($self, %params) = @_;
+
+  for my $bar ($::request->layout->get('actionbar')) {
+    $bar->add(
+      action => [
+        t8('Continue'),
+        submit    => [ '#form', { action => 'PartsPriceUpdate/update_prices' } ],
+        accesskey => 'enter',
+      ],
+
+      action => [
+        t8('Back'),
+        call => [ 'kivi.history_back' ],
+      ],
+    );
+  }
+}
+
 1;