200 |
200 |
# if multiple rowcounts (== collective order) then check if the
|
201 |
201 |
# there were more than one customer (in that case OE::retrieve removes
|
202 |
202 |
# the content from the field)
|
203 |
|
if ( $form->{rowcount} && $form->{type} eq 'sales_order'
|
204 |
|
&& defined $form->{customer} && $form->{customer} eq '') {
|
205 |
|
$form->error($locale->text('Collective Orders only work for orders from one customer!'));
|
206 |
|
}
|
|
203 |
$form->error($locale->text('Collective Orders only work for orders from one customer!'))
|
|
204 |
if $form->{rowcount} && $form->{type} eq 'sales_order'
|
|
205 |
&& defined $form->{customer} && $form->{customer} eq '');
|
207 |
206 |
|
208 |
207 |
$form->{"$form->{vc}_id"} ||= $form->{"all_$form->{vc}"}->[0]->{id} if $form->{"all_$form->{vc}"};
|
209 |
208 |
|
210 |
|
$payment_id = $form->{payment_id} if $form->{payment_id};
|
211 |
|
$language_id = $form->{language_id} if $form->{language_id};
|
212 |
|
$taxzone_id = $form->{taxzone_id} if $form->{taxzone_id};
|
213 |
|
$salesman_id = $form->{salesman_id} if $editing;
|
214 |
|
$taxincluded = $form->{taxincluded};
|
215 |
|
$cp_id = $form->{cp_id};
|
216 |
|
$intnotes = $form->{intnotes};
|
|
209 |
$form->backup_vars(qw(payment_id language_id taxzone_id salesman_id taxincluded cp_id intnotes));
|
217 |
210 |
$form->{shipto} = 1 if $form->{id};
|
218 |
211 |
|
219 |
212 |
# get customer / vendor
|
220 |
213 |
IR->get_vendor(\%myconfig, \%$form) if $form->{type} =~ /(purchase_order|request_quotation)/;
|
221 |
214 |
IS->get_customer(\%myconfig, \%$form) if $form->{type} =~ /sales_(order|quotation)/;
|
222 |
215 |
|
223 |
|
$form->{cp_id} = $cp_id;
|
224 |
|
$form->{payment_id} = $payment_id if $payment_id;
|
225 |
|
$form->{language_id} = $language_id if $language_id;
|
226 |
|
$form->{taxzone_id} = $taxzone_id if $taxzone_id;
|
227 |
|
$form->{intnotes} = $intnotes if $intnotes;
|
228 |
|
$form->{taxincluded} = $taxincluded if $form->{id};
|
229 |
|
$form->{salesman_id} = $salesman_id if $editing;
|
|
216 |
$form->restore_vars(qw(payment_id language_id taxzone_id intnotes cp_id));
|
|
217 |
$form->restore_vars(qw(taxincluded)) if $form->{id};
|
|
218 |
$form->restore_vars(qw(salesman_id)) if $editing;
|
230 |
219 |
$form->{forex} = $form->{exchangerate};
|
231 |
220 |
$form->{employee} = "$form->{employee}--$form->{employee_id}";
|
232 |
221 |
|
233 |
|
# build vendor/customer drop down
|
234 |
|
($form->{ $form->{vc} }) = split /--/, $form->{ $form->{vc} };
|
235 |
|
$form->{"old$form->{vc}"} = qq|$form->{$form->{vc}}--$form->{"$form->{vc}_id"}|;
|
236 |
|
|
237 |
|
if (@{ $form->{"all_$form->{vc}"} }) {
|
238 |
|
map { $_->{name} = $form->quote($_->{name}) } @{ $form->{"all_$form->{vc}"} };
|
239 |
|
$form->{ $form->{vc} } = qq|$form->{$form->{vc}}--$form->{"$form->{vc}_id"}|;
|
240 |
|
$form->{"select$form->{vc}"} = join "\n", map "<option>$_->{name}--$_->{id}</option>", @{ $form->{"all_$form->{vc}"} };
|
241 |
|
}
|
|
222 |
# build vendor/customer drop down comatibility... don't ask
|
|
223 |
$form->{"old$form->{vc}"} = $form->{"select$form->{vc}"} = 1;
|
242 |
224 |
|
243 |
225 |
# departments
|
244 |
226 |
if (@{ $form->{all_departments} }) {
|
... | ... | |
254 |
236 |
|
255 |
237 |
check_oe_access();
|
256 |
238 |
|
257 |
|
$form->{formname} = $form->{type} unless $form->{formname};
|
|
239 |
$form->{formname} ||= $form->{type};
|
258 |
240 |
|
259 |
|
my $i = 0;
|
260 |
241 |
foreach $ref (@{ $form->{form_details} }) {
|
261 |
|
$form->{rowcount} = ++$i;
|
262 |
|
map { $form->{"${_}_$i"} = $ref->{$_} } keys %{$ref};
|
|
242 |
$form->{rowcount}++;
|
|
243 |
map { $form->{"${_}_$form->{rowcount}"} = $ref->{$_} } keys %{$ref};
|
263 |
244 |
}
|
264 |
245 |
for my $i (1 .. $form->{rowcount}) {
|
265 |
|
$form->{"reqdate_$i"} = $form->{"deliverydate_$i"} unless $form->{"reqdate_$i"};
|
|
246 |
$form->{"reqdate_$i"} ||= $form->{"deliverydate_$i"};
|
266 |
247 |
$form->{"discount_$i"} = $form->format_amount(\%myconfig, $form->{"discount_$i"} * ($form->{id} ? 100 : 1));
|
267 |
248 |
$form->{"sellprice_$i"} = $form->format_amount(\%myconfig, $form->{"sellprice_$i"});
|
268 |
249 |
$form->{"qty_$i"} = $form->format_amount(\%myconfig, $form->{"qty_$i"});
|
Weitere, nicht ganz so behutsame Codesaeuberungen.