Einkaufs- & Verkaufsbelege: Bearbeiter*in & Verkäufer*in mit aktueller Benutzer*in...
[kivitendo-erp.git] / bin / mozilla / ic.pl
index 34915ea..24a2754 100644 (file)
@@ -94,6 +94,7 @@ sub search {
                                                                            'include_prefix' => 'l_',
                                                                            'include_value'  => 'Y');
 
+  setup_ic_search_action_bar();
   $form->header;
 
   $form->get_lists('partsgroup'    => 'ALL_PARTSGROUPS');
@@ -102,83 +103,6 @@ sub search {
   $lxdebug->leave_sub();
 }    #end search()
 
-sub search_update_prices {
-  $lxdebug->enter_sub();
-
-  $auth->assert('part_service_assembly_edit');
-
-  my $pricegroups = IC->get_pricegroups(\%myconfig, \%$form);
-
-  $form->{title} = $locale->text('Update Prices');
-
-  $form->header;
-
-  print $form->parse_html_template('ic/search_update_prices', { PRICE_ROWS => $pricegroups });
-
-  $lxdebug->leave_sub();
-}    #end search()
-
-sub confirm_price_update {
-  $lxdebug->enter_sub();
-
-  $auth->assert('part_service_assembly_edit');
-
-  my @errors      = ();
-  my $value_found = undef;
-
-  foreach my $idx (qw(sellprice listprice), (1..$form->{price_rows})) {
-    my $name      = $idx =~ m/\d/ ? $form->{"pricegroup_${idx}"}      : $idx eq 'sellprice' ? $locale->text('Sell Price') : $locale->text('List Price');
-    my $type      = $idx =~ m/\d/ ? $form->{"pricegroup_type_${idx}"} : $form->{"${idx}_type"};
-    my $value_idx = $idx =~ m/\d/ ? "price_${idx}" : $idx;
-    my $value     = $form->parse_amount(\%myconfig, $form->{$value_idx});
-
-    if ((0 > $value) && ($type eq 'percent')) {
-      push @errors, $locale->text('You cannot adjust the price for pricegroup "#1" by a negative percentage.', $name);
-
-    } elsif (!$value && ($form->{$value_idx} ne '')) {
-      push @errors, $locale->text('No valid number entered for pricegroup "#1".', $name);
-
-    } elsif (0 < $value) {
-      $value_found = 1;
-    }
-  }
-
-  push @errors, $locale->text('No prices will be updated because no prices have been entered.') if (!$value_found);
-
-  my $num_matches = IC->get_num_matches_for_priceupdate();
-
-  $form->header();
-
-  if (@errors) {
-    $form->show_generic_error(join('<br>', @errors));
-  }
-
-  $form->{nextsub} = "update_prices";
-
-  map { delete $form->{$_} } qw(action header);
-
-  print $form->parse_html_template('ic/confirm_price_update', { HIDDENS     => [ map { name => $_, value => $form->{$_} }, keys %$form ],
-                                                                num_matches => $num_matches });
-
-  $lxdebug->leave_sub();
-}
-
-sub update_prices {
-  $lxdebug->enter_sub();
-
-  $auth->assert('part_service_assembly_edit');
-
-  my $num_updated = IC->update_prices(\%myconfig, \%$form);
-
-  if (-1 != $num_updated) {
-    $form->redirect($locale->text('#1 prices were updated.', $num_updated));
-  } else {
-    $form->error($locale->text('Could not update prices!'));
-  }
-
-  $lxdebug->leave_sub();
-}
-
 sub top100 {
   $::lxdebug->enter_sub();
 
@@ -270,7 +194,7 @@ sub generate_report {
     'serialnumber'       => { 'text' => $locale->text('Serial Number'), },
     'soldtotal'          => { 'text' => $locale->text('Qty in Selected Records'), },
     'name'               => { 'text' => $locale->text('Name in Selected Records'), },
-    'transdate'          => { 'text' => $locale->text('Transdate'), },
+    'transdate'          => { 'text' => $locale->text('Transdate Record'), },
     'unit'               => { 'text' => $locale->text('Unit'), },
     'weight'             => { 'text' => $locale->text('Weight'), },
     'shop'               => { 'text' => $locale->text('Shop article'), },
@@ -481,7 +405,7 @@ sub generate_report {
 
   my @hidden_variables = (
     qw(l_subtotal l_linetotal searchitems itemstatus bom l_pricegroups insertdatefrom insertdateto),
-    qw(l_type_and_classific classification_id),
+    qw(l_type_and_classific classification_id l_part l_service l_assembly l_assortment),
     @itemstatus_keys,
     @callback_keys,
     map({ "cvar_$_->{name}" } @searchable_custom_variables),
@@ -663,17 +587,58 @@ sub generate_report {
     $report->add_data($row);
   }
 
+  setup_ic_generate_report_action_bar();
   $report->generate_with_headers();
 
   $lxdebug->leave_sub();
 }    #end generate_report
 
-sub continue { call_sub($form->{"nextsub"}); }
-
-sub dispatcher {
-  my $action = first { $::form->{"action_${_}"} } qw(add);
-  $::form->error($::locale->text('No action defined.')) unless $action;
+sub setup_ic_search_action_bar {
+  my %params = @_;
+
+  for my $bar ($::request->layout->get('actionbar')) {
+    $bar->add(
+      action => [
+        t8('Search'),
+        submit    => [ '#form', { action => 'generate_report' } ],
+        accesskey => 'enter',
+      ],
+
+      action => [
+        t8('TOP100'),
+        submit => [ '#form', { action => 'top100' } ],
+      ],
+    );
+  }
+}
 
-  $::form->{dispatched_action} = $action;
-  call_sub($action);
+sub setup_ic_generate_report_action_bar {
+  my %params = @_;
+
+  for my $bar ($::request->layout->get('actionbar')) {
+    $bar->add(
+      combobox => [
+        action => [
+          t8('Add'),
+        ],
+        action => [
+          t8('Add Part'),
+          submit    => [ '#new_form', { action => 'Part/add_part' } ],
+          accesskey => 'enter',
+        ],
+        action => [
+          t8('Add Service'),
+          submit    => [ '#new_form', { action => 'Part/add_service' } ],
+        ],
+        action => [
+          t8('Add Assembly'),
+          submit    => [ '#new_form', { action => 'Part/add_assembly' } ],
+        ],
+        action => [
+          t8('Add Assortment'),
+          submit    => [ '#new_form', { action => 'Part/add_assortment' } ],
+        ],
+      ], # end of combobox "Add part"
+    );
+  }
 }