# -------------------------------------------------------------------------
-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();
"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."));
# --------------------------------------------------------------------
sub transfer_assembly_update_part {
- $main::lxdebug->enter_sub();
-
my $form = $main::form;
my %myconfig = %main::myconfig;
my $locale = $main::locale;
$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 {
+++ /dev/null
-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);
-}
-
'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',
'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',
'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',
'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',
'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.',
'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:',
'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',
+++ /dev/null
-[%- USE T8 %]
-[%- USE HTML %]
-<h1>[% title %]</h1>
-
- <form action="[% HTML.escape(script) %]" method="post" name="Form">
-
- <input type="hidden" name="input_partnumber" value="[% HTML.escape(input_partnumber) %]">
- <input type="hidden" name="input_description" value="[% HTML.escape(input_description) %]">
- <input type="hidden" name="input_partsid" value="[% HTML.escape(input_partsid) %]">
- <input type="hidden" name="input_partnotes" value="[% HTML.escape(input_partnotes) %]">
- <input type="hidden" name="allow_creation" value="[% HTML.escape(allow_creation) %]">
- <input type="hidden" name="action_on_part_selected" value="[% HTML.escape(action_on_part_selected) %]">
- <input type="hidden" name="filter" value="[% HTML.escape(filter) %]">
- <input type="hidden" name="options" value="[% HTML.escape(options) %]">
- <input type="hidden" name="new_description" value="[% HTML.escape(description) %]">
-
- <table width="100%">
- <tr>
- <td>
- [% IF no_parts_found %]
- [% 'No part was found matching the search parameters.' | $T8 %]
- [% IF allow_creation %]
- [% 'However, you can create a new part which will then be selected.' | $T8 %]
- [% END %]
- [% ELSE %]
- [% 'Please select a part from the list below.' | $T8 %]
- [% IF allow_creation %]
- [% 'Alternatively you can create a new part which will then be selected.' | $T8 %]
- [% END %]
- [% END %]
- </td>
- </tr>
-
- [% UNLESS no_parts_found %]
- <tr>
- <td>
- <table>
- <tr class="listheading">
- <th class="listheading"> </th>
- [% FOREACH header = HEADER %]
- <th nowrap class="listheading"><a href="[% HTML.escape(header.callback) %]">[% header.column_title %]</a></th>
- [% END %]
- </tr>
-
- [% FOREACH part = PARTS %]
- <tr class="listrow[% IF loop.count % 2 %]1[% ELSE %]0[% END %]">
- <td><button type="button" onclick="part_selected('[% loop.count %]')">[% 'Select' | $T8 %]</button></td>
- <td>
- <input type="hidden" id="partsid_[% loop.count %]" name="partsid_[% loop.count %]" value="[% HTML.escape(part.id) %]">
- <input type="hidden" id="partnumber_[% loop.count %]" name="partnumber_[% loop.count %]" value="[% HTML.escape(part.partnumber) %]">
- [% HTML.escape(part.partnumber) %]
- </td>
- <td>
- <input type="hidden" id="description_[% loop.count %]" name="description_[% loop.count %]" value="[% HTML.escape(part.description) %]">
- <input type="hidden" id="partnotes_[% loop.count %]" name="partnotes_[% loop.count %]" value="[% HTML.escape(part.partnotes) %]">
- [% HTML.escape(part.description) %]
- </td>
-<!-- <td> -->
-<!-- <input type="hidden" id="onhand_[% loop.count %]" name="onhand_[% loop.count %]" value="[% HTML.escape(part.onhand) %]"> -->
-<!-- [% HTML.escape(part.onhand) %] -->
-<!-- </td> -->
- </tr>
- [% END %]
- </table>
- </td>
- </tr>
- [% END %]
- </table>
-
- [% IF allow_creation %]
- <p><input type="submit" name="action" value="[% 'New part' | $T8 %]"></p>
- [% END %]
-
- </form>
-
- <script type="text/javascript">
- <!--
- function part_selected(selected) {
- var partnumber = document.getElementsByName("partnumber_" + selected)[0].value;
- var description = document.getElementsByName("description_" + selected)[0].value;
- var partsid = document.getElementsByName("partsid_" + selected)[0].value;
- var partnotes = document.getElementsByName("partnotes_" + selected)[0].value;
- var pnum_name = document.Form.input_partnumber.value;
- window.opener.document.getElementsByName(pnum_name)[0].value = partnumber;
- window.opener.document.getElementsByName(document.Form.input_description.value)[0].value = description;
- if (document.Form.input_partsid.value != "") {
- window.opener.document.getElementsByName(document.Form.input_partsid.value)[0].value = partsid;
- }
- if (document.Form.input_partnotes.value != "") {
- var el = window.opener.document.getElementsByName(document.Form.input_partnotes.value)[0];
- if (el)
- el.value = partnotes;
- }
- if (document.Form.action_on_part_selected.value != "") {
- window.opener.document.getElementsByName("action")[0].value = document.Form.action_on_part_selected.value;
- window.opener.document.[% formname %].submit();
- }
-
-
- var prefix = "";
- if (pnum_name.substr(0, 2) == "f_") {
- prefix = "f_";
- pnum_name = pnum_name.substr(2);
- }
- pnum_name = prefix + "old_" + pnum_name;
- var input = window.opener.document.getElementsByName(pnum_name)[0];
- if (input) {
- input.value = name;
- }
-
- [%- IF click_button %]
- window.opener.document.[% formname %].[% click_button %].click();
- [%- END %]
-
- self.close();
- }
- //-->
- </script>
-
+++ /dev/null
-[%- USE T8 %]
-[%- USE HTML %]
- <form method="post" action="[% HTML.escape(script) %]">
-
- <input type="hidden" name="nextsub" value="[% HTML.escape(nextsub) %]">
- <input type="hidden" name="callback_sub" value="[% HTML.escape(callback_sub) %]">
-
- <input type="hidden" name="old_form" value="[% HTML.escape(old_form) %]">
- <input type="hidden" name="remap_parts_id" value="[% HTML.escape(remap_parts_id) %]">
- <input type="hidden" name="remap_partnumber" value="[% HTML.escape(remap_partnumber) %]">
-
- <h1>[% 'Select a part or assembly' | $T8 %]</h1>
-
- <p>
- <table>
- <tr>
- <th class="listheading"> </th>
- <th class="listheading">[% 'Number' | $T8 %]</th>
- <th class="listheading">[% 'Description' | $T8 %]</th>
- [% IF has_charge %]
- <th class="listheading">[% 'Charge number' | $T8 %]</th>
- [% END %]
- [% IF has_bestbefore %]
- [% IF INSTANCE_CONF.get_show_bestbefore %]
- <th class="listheading">[% 'Best Before' | $T8 %]</th>
- [% END %]
- [% END %]
- [% IF has_ean %]
- <th class="listheading">[% 'EAN' | $T8 %]</th>
- [% END %]
- </tr>
-
- [% FOREACH part = PARTS %]
- <tr class="listrow[% loop.count % 2 %]">
- <td>
- <input type="radio" name="selection" value="[% loop.count %]"[% IF loop.first %] checked[% END %]>
- </td>
-
- <td>
- <input type="hidden" name="new_id_[% loop.count %]" value="[% HTML.escape(part.id) %]">
- <input type="hidden" name="new_number_[% loop.count %]" value="[% HTML.escape(part.number) %]">
- <input type="hidden" name="new_warehouse_id_[% loop.count %]" value="[% HTML.escape(part.warehouse_id) %]">
- <input type="hidden" name="new_bin_id_[% loop.count %]" value="[% HTML.escape(part.bin_id) %]">
- [% HTML.escape(part.number) %]
- </td>
-
- <td>
- <input type="hidden" name="new_description_[% loop.count %]" value="[% HTML.escape(part.description) %]">
- [% HTML.escape(part.description) %]
- </td>
-
- [% IF has_charge %]
- <td>
- <input type="hidden" name="new_charge_id_[% loop.count %]" value="[% HTML.escape(part.charge_id) %]">
- <input type="hidden" name="new_chargenumber_[% loop.count %]" value="[% HTML.escape(part.chargenumber) %]">
- [% HTML.escape(part.chargenumber) %]
- </td>
- [% END %]
- [% IF has_bestbefore %]
- [% IF INSTANCE_CONF.get_show_bestbefore %]
- <td>
- <input type="hidden" name="new_bestbefore_id_[% loop.count %]" value="[% HTML.escape(part.bestbefore_id) %]">
- <input type="hidden" name="new_bestbefore_[% loop.count %]" value="[% HTML.escape(part.bestbefore) %]">
- [% HTML.escape(part.bestbefore) %]
- </td>
- [% END %]
- [% END %]
- [% IF has_ean %]
- <td>
- <input type="hidden" name="new_ean_[% loop.count %]" value="[% HTML.escape(part.ean) %]">
- [% HTML.escape(part.ean) %]
- [% END %]
- </td>
- </tr>
- [% END %]
- </table>
- </p>
-
- <p>
- <input type="submit" class="submit" name="action" value="[% 'Continue' | $T8 %]">
- </p>
-
- </form>
-
[%- USE T8 %]
[%- USE HTML %]
[%- USE L %]
-[%- USE JavaScript %]
+[%- USE JavaScript %][%- USE P -%]
<h1>[% title %]</h1>
- <script type="text/javascript" src="js/common.js"></script>
- <script type="text/javascript" src="js/part_selection.js"></script>
<script type="text/javascript">
<!--
warehouses = new Array();
</tr>
<tr>
- <th align="right" nowrap>[% 'Part Number' | $T8 %]</th>
+ <th align="right" nowrap>[% 'Part' | $T8 %]</th>
<td>
- <input type="hidden" name="parts_id" id="parts_id">
- <input name="partnumber" id="partnumber" size="30">
- </td>
- </tr>
-
- <tr>
- <th align="right" nowrap>[% 'Part Description' | $T8 %]</th>
- <td>
- <input name="description" size="30">
- <input type="button" onclick="part_selection_window('partnumber', 'description', 'parts_id', 0, 'Form', '')" value="?">
+ [% P.part_picker("part_id", '', size="30", part_type="part,assembly") %]
</td>
</tr>
[%- USE T8 %]
[%- USE L %]
-[%- USE HTML %][%- USE JavaScript %][%- USE LxERP %]
+[%- USE HTML %][%- USE JavaScript %][%- USE LxERP %][%- USE P -%]
<h1>[% title %]</h1>
- <script type="text/javascript" src="js/common.js"></script>
- <script type="text/javascript" src="js/part_selection.js"></script>
<script type="text/javascript">
<!--
warehouses = new Array();
</tr>
<tr>
- <th align="right" nowrap>[% 'Assembly Number' | $T8 %]</th>
+ <th align="right" nowrap>[% 'Assembly' | $T8 %]</th>
<td>
- <input type="hidden" name="parts_id" id="parts_id" value="[% HTML.escape(parts_id) %]">
- <input type="hidden" name="old_partnumber" id="old_partnumber" value="[% HTML.escape(partnumber) %]">
- <input name="partnumber" size="30" value="[% HTML.escape(partnumber) %]">
- </td>
- </tr>
-
- <tr>
- <th align="right" nowrap>[% 'Assembly Description' | $T8 %]</th>
- <td>
- <input name="description" size="30" value="[% HTML.escape(description) %]">
- <input type="button" onclick="part_selection_window('partnumber', 'description', 'parts_id', 0, 'Form', 'assemblies:click_button=update_button')" value="?">
+ [% P.part_picker("parts_id", parts_id, part_type="assembly") %]
</td>
</tr>