From 5d4977002a6a8476575ca3e0f0935effa200912a Mon Sep 17 00:00:00 2001
From: Moritz Bunkus
Date: Tue, 17 Jan 2017 13:53:47 +0100
Subject: [PATCH] Lager: Umstellung auf Verwendung vom Part-Picker
MIME-Version: 1.0
Content-Type: text/plain; charset=utf8
Content-Transfer-Encoding: 8bit
Dadurch wurden mehrere alte Artikel-Auswahl-Routinen und -Vorlagen
überflüssig, die gleich entfernt wurden.
---
bin/mozilla/common.pl | 152 ------------------
bin/mozilla/wh.pl | 35 ++--
js/part_selection.js | 43 -----
locale/de/all | 9 --
.../webpages/generic/part_selection.html | 119 --------------
templates/webpages/generic/select_part.html | 84 ----------
.../webpages/wh/warehouse_selection.html | 17 +-
.../wh/warehouse_selection_assembly.html | 18 +--
8 files changed, 16 insertions(+), 461 deletions(-)
delete mode 100644 js/part_selection.js
delete mode 100644 templates/webpages/generic/part_selection.html
delete mode 100644 templates/webpages/generic/select_part.html
diff --git a/bin/mozilla/common.pl b/bin/mozilla/common.pl
index d01d19f58..52366a0e3 100644
--- a/bin/mozilla/common.pl
+++ b/bin/mozilla/common.pl
@@ -53,158 +53,6 @@ sub build_std_url {
# -------------------------------------------------------------------------
-sub select_part {
- $main::lxdebug->enter_sub();
-
- my ($callback_sub, @parts) = @_;
-
- my $form = $main::form;
- my $locale = $main::locale;
-
- my $remap_parts_id = 0;
- if (defined($parts[0]->{parts_id}) && !defined($parts[0]->{id})) {
- $remap_parts_id = 1;
- map { $_->{id} = $_->{parts_id}; } @parts;
- }
-
- my $remap_partnumber = 0;
- if (defined($parts[0]->{partnumber}) && !defined($parts[0]->{number})) {
- $remap_partnumber = 1;
- map { $_->{number} = $_->{partnumber}; } @parts;
- }
-
- my $has_charge = 0;
- if (defined($parts[0]->{chargenumber})) {
- $has_charge = 1;
- map { $_->{has_charge} = 1; } @parts;
- }
- my $has_bestbefore = 0;
- if (defined($parts[0]->{bestbefore})) {
- $has_bestbefore = 1;
- map { $_->{has_bestbefore} = 1; } @parts;
- }
- my $has_ean = 0;
- if (defined($parts[0]->{ean})) {
- $has_ean = 1;
- map { $_->{has_ean} = 1; } @parts;
- }
-
- my $old_form = save_form();
-
- $form->header();
- print $form->parse_html_template("generic/select_part",
- { "PARTS" => \@parts,
- "old_form" => $old_form,
- "title" => $locale->text("Select a part"),
- "nextsub" => "select_part_internal",
- "callback_sub" => $callback_sub,
- "has_charge" => $has_charge,
- "has_bestbefore" => $has_bestbefore,
- "has_ean" => $has_ean,
- "remap_parts_id" => $remap_parts_id,
- "remap_partnumber" => $remap_partnumber });
-
- $main::lxdebug->leave_sub();
-}
-
-sub select_part_internal {
- $main::lxdebug->enter_sub();
-
- my $form = $main::form;
-
- my ($new_item, $callback_sub);
-
- my $re = "^new_.*_$form->{selection}\$";
-
- foreach (grep /$re/, keys %{ $form }) {
- my $new_key = $_;
- $new_key =~ s/^new_//;
- $new_key =~ s/_\d+$//;
- $new_item->{$new_key} = $form->{$_};
- }
-
- if ($form->{remap_parts_id}) {
- $new_item->{parts_id} = $new_item->{id};
- delete $new_item->{id};
- }
-
- if ($form->{remap_partnumber}) {
- $new_item->{partnumber} = $new_item->{number};
- delete $new_item->{number};
- }
-
- $callback_sub = $form->{callback_sub};
-
- restore_form($form->{old_form});
-
- call_sub($callback_sub, $new_item);
-
- $main::lxdebug->leave_sub();
-}
-
-sub part_selection_internal {
- $main::lxdebug->enter_sub();
-
- my $form = $main::form;
- my %myconfig = %main::myconfig;
- my $locale = $main::locale;
-
- my $order_by = "description";
- $order_by = $form->{"order_by"} if (defined($form->{"order_by"}));
- my $order_dir = 1;
- $order_dir = $form->{"order_dir"} if (defined($form->{"order_dir"}));
-
- my %options;
-
- foreach my $opt (split m/:/, $form->{options}) {
- if ($opt =~ /=/) {
- my ($key, $value) = split m/=/, $opt, 2;
- $options{$key} = $value;
-
- } else {
- $options{$opt} = 1;
- }
- }
-
- map { $form->{$_} = $options{$_} if ($options{$_}) } qw(no_services no_assemblies assemblies click_button);
-
- my $parts = Common->retrieve_parts(\%myconfig, $form, $order_by, $order_dir);
-
- if (0 == scalar(@{$parts})) {
- $form->show_generic_information($locale->text("No part was found matching the search parameters."));
- } elsif (1 == scalar(@{$parts})) {
- $::request->{layout}->add_javascripts_inline("part_selected('1')");
- }
-
- map { $parts->[$_]->{selected} = $_ ? 0 : 1; } (0..$#{$parts});
-
- my $callback = build_std_url('action=part_selection_internal', qw(partnumber description input_partnumber input_description input_partsid),
- grep({ /^[fl]_/ } keys %{ $form }));
-
- my @header_sort = qw(partnumber description);
- my %header_title = ( "partnumber" => $locale->text("Part Number"),
- "description" => $locale->text("Part Description"),
- );
-
- my @header =
- map(+{ "column_title" => $header_title{$_},
- "column" => $_,
- "callback" => $callback . "order_by=${_}&order_dir=" . ($order_by eq $_ ? 1 - $order_dir : $order_dir),
- },
- @header_sort);
-
- $form->{formname} ||= 'Form';
-
- $form->{title} = $locale->text("Select a part");
- $form->header(no_layout => 1);
- print $form->parse_html_template("generic/part_selection", { "HEADER" => \@header,
- "PARTS" => $parts, });
-
- $main::lxdebug->leave_sub();
-}
-
-# -------------------------------------------------------------------------
-
sub delivery_customer_selection {
$main::lxdebug->enter_sub();
diff --git a/bin/mozilla/wh.pl b/bin/mozilla/wh.pl
index e64224aa8..2ef05a608 100644
--- a/bin/mozilla/wh.pl
+++ b/bin/mozilla/wh.pl
@@ -178,9 +178,8 @@ sub transfer_or_removal_prepare_contents {
"bin_id" => $form->{bin_id},
"chargenumber" => $form->{chargenumber},
"bestbefore" => $form->{bestbefore},
- "partnumber" => $form->{partnumber},
- "ean" => $form->{ean},
- "description" => $form->{description});
+ "partsid" => $form->{part_id},
+ "ean" => $form->{ean});
if (0 == scalar(@contents)) {
$form->show_generic_error($locale->text("The selected warehouse is empty, or no stocked items where found that match the filter settings."));
@@ -313,8 +312,6 @@ sub transfer_parts {
# --------------------------------------------------------------------
sub transfer_assembly_update_part {
- $main::lxdebug->enter_sub();
-
my $form = $main::form;
my %myconfig = %main::myconfig;
my $locale = $main::locale;
@@ -322,30 +319,18 @@ sub transfer_assembly_update_part {
$form->{trans_type} = 'assembly';
$form->{qty} = $form->parse_amount(\%myconfig, $form->{qty});
- if (!$form->{partnumber} && !$form->{description}) {
- delete @{$form}{qw(parts_id partunit)};
+ if (!$form->{parts_id}) {
+ delete $form->{partunit};
transfer_warehouse_selection();
+ return;
- } elsif (($form->{partnumber} && ($form->{partnumber} ne $form->{old_partnumber})) || $form->{description}) {
- $form->{assemblies} = 1;
- $form->{no_assemblies} = 0;
- my $parts = Common->retrieve_parts(\%myconfig, $form, 'description', 1);
- if (scalar @{ $parts } == 1) {
- @{$form}{qw(parts_id partnumber description)} = @{$parts->[0]}{qw(id partnumber description)};
- transfer_stock_get_partunit();
- transfer_warehouse_selection();
- } else {
- select_part('transfer_stock_part_selected', @{ $parts });
- }
-
- } else {
- transfer_stock_get_partunit();
- transfer_warehouse_selection();
}
-# hier die oben benannte idee
-# my $maxcreate = Common->check_assembly_max_create(assembly_id => $form->{parts_id}, dbh => $my_dbh);
- $main::lxdebug->leave_sub();
+ my $part = SL::DB::Part->new(id => $::form->{parts_id})->load;
+ @{$form}{qw(parts_id partnumber description)} = ($part->id, $part->partnumber, $part->description);
+
+ transfer_stock_get_partunit();
+ transfer_warehouse_selection();
}
sub transfer_stock_part_selected {
diff --git a/js/part_selection.js b/js/part_selection.js
deleted file mode 100644
index 9fd565723..000000000
--- a/js/part_selection.js
+++ /dev/null
@@ -1,43 +0,0 @@
-function part_selection_window(input_partnumber, input_description, input_partsid, allow_creation, formname, options) {
- var width = allow_creation ? 1000 : 800;
- var parm = centerParms(width,500) + ",width=" + width + ",height=500,status=yes,scrollbars=yes";
- var partnumber = document.getElementsByName(input_partnumber)[0].value;
- var description = document.getElementsByName(input_description)[0].value;
- var action_on_part_selected = document.getElementsByName("action_on_part_selected")[0];
- var form = (formname == undefined) ? document.forms[0] : document.getElementsByName(formname)[0];
- var filter = document.getElementsByName(input_partnumber + "_filter")[0];
- var input_partnotes = "";
-
- if (input_partnumber.match(/_\d+$/)) {
- input_partnotes = input_partnumber;
- input_partnotes = input_partnotes.replace(/partnumber/, "partnotes");
- if (input_partnotes == input_partnumber)
- input_partnotes = "";
- }
-
- if (filter)
- filter = filter.value;
- else
- filter = "";
-
- if (!options)
- options = "";
-
- url = "common.pl?" +
- "INPUT_ENCODING=UTF-8&" +
- "action=part_selection_internal&" +
- "partnumber=" + encodeURIComponent(partnumber) + "&" +
- "description=" + encodeURIComponent(description) + "&" +
- "input_partnumber=" + encodeURIComponent(input_partnumber) + "&" +
- "input_description=" + encodeURIComponent(input_description) + "&" +
- "input_partsid=" + encodeURIComponent(input_partsid) + "&" +
- "input_partnotes=" + encodeURIComponent(input_partnotes) + "&" +
- "filter=" + encodeURIComponent(filter) + "&" +
- "options=" + encodeURIComponent(options) + "&" +
- "formname=" + encodeURIComponent(formname) + "&" +
- "allow_creation=" + (allow_creation ? "1" : "0") + "&" +
- "action_on_part_selected=" + (null == action_on_part_selected ? "" : action_on_part_selected.value);
- //alert(url);
- window.open(url, "_new_part_selection", parm);
-}
-
diff --git a/locale/de/all b/locale/de/all
index da4278f9d..688086ae4 100755
--- a/locale/de/all
+++ b/locale/de/all
@@ -248,7 +248,6 @@ $self->{texts} = {
'Allow direct creation of new purchase delivery orders' => 'Direktes Anlegen neuer Einkaufslieferscheine zulassen',
'Allow direct creation of new purchase invoices' => 'Direktes Anlegen neuer Einkaufsrechnungen zulassen',
'Allow the following users access to my follow-ups:' => 'Erlaube den folgenden Benutzern Zugriff auf meine Wiedervorlagen:',
- 'Alternatively you can create a new part which will then be selected.' => 'Sie können auch einen neuen Artikel anlegen, der dann automatisch ausgewählt wird.',
'Always save orders with a projectnumber (create new projects)' => 'Aufträge immer mit Projektnummer speichern (neue Projekt erstellen)',
'Amended Advance Turnover Tax Return' => 'Berichtigte Anmeldung',
'Amount' => 'Betrag',
@@ -304,8 +303,6 @@ $self->{texts} = {
'Assemblies' => 'Erzeugnisse',
'Assembly' => 'Erzeugnis',
'Assembly (typeabbreviation)' => 'E',
- 'Assembly Description' => 'Erzeugnis-Beschreibung',
- 'Assembly Number' => 'Erzeugnis-Nummer',
'Assembly Number missing!' => 'Erzeugnisnummer fehlt!',
'Assembly items' => 'Erzeugnisbestandteile',
'Asset' => 'Aktiva/Mittelverwendung',
@@ -1428,7 +1425,6 @@ $self->{texts} = {
'Hourly Rate' => 'Stundensatz',
'Hourly rate' => 'Stundensatz',
'How many do you want to create and print?' => 'Wie viele wollen Sie erstellen und drucken?',
- 'However, you can create a new part which will then be selected.' => 'Sie können jedoch einen neuen Artikel anlegen, der dann automatisch ausgewählt wird.',
'I' => 'I',
'IBAN' => 'IBAN',
'ID' => 'Buchungsnummer',
@@ -1797,7 +1793,6 @@ $self->{texts} = {
'New filter for tax accounts' => 'Neue Filter für Steuerkonten',
'New invoice' => 'Neue Rechnung',
'New name' => 'Neuer Name',
- 'New part' => 'Neue Ware',
'New row, description' => 'Neue Zeile, Artikelbeschreibung',
'New row, partnumber' => 'Neue Zeile, Nummer',
'New row, qty' => 'Neue Zeile, Menge',
@@ -1845,7 +1840,6 @@ $self->{texts} = {
'No internal phone extensions have been configured yet.' => 'Es wurden noch keine internen Durchwahlen konfiguriert.',
'No invoices have been selected.' => 'Es wurden keine Rechnungen ausgewählt.',
'No or an unknown authenticantion module specified in "config/kivitendo.conf".' => 'Es wurde kein oder ein unbekanntes Authentifizierungsmodul in "config/kivitendo.conf" angegeben.',
- 'No part was found matching the search parameters.' => 'Es wurde kein Artikel gefunden, auf den die Suchparameter zutreffen.',
'No part was selected.' => 'Es wurde kein Artikel ausgewählt',
'No parts classification has been created yet.' => 'Keine Artikel-Klassifizierung erzeugt.',
'No payment term has been created yet.' => 'Es wurden noch keine Zahlungsbedingungen angelegt.',
@@ -2120,7 +2114,6 @@ $self->{texts} = {
'Please read the file' => 'Bitte lesen Sie die Datei',
'Please select a customer from the list below.' => 'Bitte einen Endkunden aus der Liste auswählen',
'Please select a customer.' => 'Bitte wählen Sie einen Kunden aus.',
- 'Please select a part from the list below.' => 'Bitte wählen Sie einen Artikel aus der Liste aus.',
'Please select a vendor from the list below.' => 'Bitte einen Händler aus der Liste auswählen',
'Please select a vendor.' => 'Bitte wählen Sie einen Lieferanten aus.',
'Please select the dataset you want to delete:' => 'Bitte wählen Sie die zu löschende Datenbank aus:',
@@ -2517,8 +2510,6 @@ $self->{texts} = {
'Select Mulit-Item Options' => 'Multi-Treffer Auswahlliste',
'Select a Customer' => 'Endkunde auswählen',
'Select a customer' => 'Einen Kunden auswählen',
- 'Select a part' => 'Artikel auswählen',
- 'Select a part or assembly' => 'Artikel oder Erzeugnis auswählen',
'Select a period' => 'Bitte Zeitraum auswählen',
'Select a vendor' => 'Einen Lieferanten auswählen',
'Select all' => 'Alle auswählen',
diff --git a/templates/webpages/generic/part_selection.html b/templates/webpages/generic/part_selection.html
deleted file mode 100644
index 974533444..000000000
--- a/templates/webpages/generic/part_selection.html
+++ /dev/null
@@ -1,119 +0,0 @@
-[%- USE T8 %]
-[%- USE HTML %]
-
[% title %]
-
-
-
-
-
diff --git a/templates/webpages/generic/select_part.html b/templates/webpages/generic/select_part.html
deleted file mode 100644
index 300bf06cb..000000000
--- a/templates/webpages/generic/select_part.html
+++ /dev/null
@@ -1,84 +0,0 @@
-[%- USE T8 %]
-[%- USE HTML %]
-
-
-
-
-
-
-
-
diff --git a/templates/webpages/wh/warehouse_selection.html b/templates/webpages/wh/warehouse_selection.html
index 6b48f4014..6c20594e7 100644
--- a/templates/webpages/wh/warehouse_selection.html
+++ b/templates/webpages/wh/warehouse_selection.html
@@ -1,11 +1,9 @@
[%- USE T8 %]
[%- USE HTML %]
[%- USE L %]
-[%- USE JavaScript %]
+[%- USE JavaScript %][%- USE P -%]