Revision 83914eeb
Von Moritz Bunkus vor fast 17 Jahren hinzugefügt
bin/mozilla/common.pl | ||
---|---|---|
47 | 47 |
|
48 | 48 |
# ------------------------------------------------------------------------- |
49 | 49 |
|
50 |
sub select_part { |
|
51 |
$lxdebug->enter_sub(); |
|
52 |
|
|
53 |
my ($callback_sub, @parts) = @_; |
|
54 |
|
|
55 |
my $remap_parts_id = 0; |
|
56 |
if (defined($parts[0]->{parts_id}) && !defined($parts[0]->{id})) { |
|
57 |
$remap_parts_id = 1; |
|
58 |
map { $_->{id} = $_->{parts_id}; } @parts; |
|
59 |
} |
|
60 |
|
|
61 |
my $remap_partnumber = 0; |
|
62 |
if (defined($parts[0]->{partnumber}) && !defined($parts[0]->{number})) { |
|
63 |
$remap_partnumber = 1; |
|
64 |
map { $_->{number} = $_->{partnumber}; } @parts; |
|
65 |
} |
|
66 |
|
|
67 |
my $has_charge = 0; |
|
68 |
if (defined($parts[0]->{chargenumber})) { |
|
69 |
$has_charge = 1; |
|
70 |
map { $_->{has_charge} = 1; } @parts; |
|
71 |
} |
|
72 |
|
|
73 |
my $old_form = save_form(); |
|
74 |
|
|
75 |
$form->header(); |
|
76 |
print $form->parse_html_template("generic/select_part", |
|
77 |
{ "PARTS" => \@parts, |
|
78 |
"old_form" => $old_form, |
|
79 |
"title" => $locale->text("Select a part"), |
|
80 |
"nextsub" => "select_part_internal", |
|
81 |
"callback_sub" => $callback_sub, |
|
82 |
"has_charge" => $has_charge, |
|
83 |
"remap_parts_id" => $remap_parts_id, |
|
84 |
"remap_partnumber" => $remap_partnumber }); |
|
85 |
|
|
86 |
$lxdebug->leave_sub(); |
|
87 |
} |
|
88 |
|
|
89 |
sub select_part_internal { |
|
90 |
$lxdebug->enter_sub(); |
|
91 |
|
|
92 |
my ($new_item, $callback_sub); |
|
93 |
|
|
94 |
my $re = "^new_.*_" . $form->{selection}; |
|
95 |
|
|
96 |
foreach (grep /$re/, keys %{ $form }) { |
|
97 |
my $new_key = $_; |
|
98 |
$new_key =~ s/^new_//; |
|
99 |
$new_key =~ s/_\d+$//; |
|
100 |
$new_item->{$new_key} = $form->{$_}; |
|
101 |
} |
|
102 |
|
|
103 |
if ($form->{remap_parts_id}) { |
|
104 |
$new_item->{parts_id} = $new_item->{id}; |
|
105 |
delete $new_item->{id}; |
|
106 |
} |
|
107 |
|
|
108 |
if ($form->{remap_partnumber}) { |
|
109 |
$new_item->{partnumber} = $new_item->{number}; |
|
110 |
delete $new_item->{number}; |
|
111 |
} |
|
112 |
|
|
113 |
my $callback_sub = $form->{callback_sub}; |
|
114 |
|
|
115 |
restore_form($form->{old_form}); |
|
116 |
|
|
117 |
call_sub($callback_sub, $new_item); |
|
118 |
|
|
119 |
$lxdebug->leave_sub(); |
|
120 |
} |
|
121 |
|
|
122 |
sub part_selection_internal { |
|
123 |
$lxdebug->enter_sub(); |
|
124 |
|
|
125 |
$order_by = "description"; |
|
126 |
$order_by = $form->{"order_by"} if (defined($form->{"order_by"})); |
|
127 |
$order_dir = 1; |
|
128 |
$order_dir = $form->{"order_dir"} if (defined($form->{"order_dir"})); |
|
129 |
|
|
130 |
%options = map { $_ => 1 } split m/:/, $form->{options}; |
|
131 |
|
|
132 |
map { $form->{$_} = 1 if ($options{$_}) } qw(no_services no_assemblies stockable); |
|
133 |
|
|
134 |
$parts = Common->retrieve_parts(\%myconfig, $form, $order_by, $order_dir); |
|
135 |
|
|
136 |
if (0 == scalar(@{$parts})) { |
|
137 |
$form->show_generic_information($locale->text("No part was found matching the search parameters.")); |
|
138 |
} elsif (1 == scalar(@{$parts})) { |
|
139 |
$onload = "part_selected('1')"; |
|
140 |
} |
|
141 |
|
|
142 |
map { $parts->[$_]->{selected} = $_ ? 0 : 1; } (0..$#{$parts}); |
|
143 |
|
|
144 |
my $callback = build_std_url('action=part_selection_internal', qw(partnumber description input_partnumber input_description input_partsid), |
|
145 |
grep({ /^[fl]_/ } keys %{ $form })); |
|
146 |
|
|
147 |
my @header_sort = qw(partnumber description); |
|
148 |
my %header_title = ( "partnumber" => $locale->text("Part Number"), |
|
149 |
"description" => $locale->text("Part description"), |
|
150 |
); |
|
151 |
|
|
152 |
my @header = |
|
153 |
map(+{ "column_title" => $header_title{$_}, |
|
154 |
"column" => $_, |
|
155 |
"callback" => $callback . "order_by=${_}&order_dir=" . ($order_by eq $_ ? 1 - $order_dir : $order_dir), |
|
156 |
}, |
|
157 |
@header_sort); |
|
158 |
|
|
159 |
$form->{title} = $locale->text("Select a part"); |
|
160 |
$form->header(); |
|
161 |
print $form->parse_html_template("generic/part_selection", { "HEADER" => \@header, |
|
162 |
"PARTS" => $parts, |
|
163 |
"onload" => $onload }); |
|
164 |
|
|
165 |
$lxdebug->leave_sub(); |
|
166 |
} |
|
167 |
|
|
168 |
# ------------------------------------------------------------------------- |
|
169 |
|
|
50 | 170 |
sub delivery_customer_selection { |
51 | 171 |
$lxdebug->enter_sub(); |
52 | 172 |
|
Auch abrufbar als: Unified diff
Lagerverwaltung implementiert.