do_statement($form, $h_item_id, $q_item_id);
my ($item_id) = $h_item_id->fetchrow_array();
+ # Get pricegroup_id and save it. Unfortunately the interface
+ # also uses ID "0" for signalling that none is selected, but "0"
+ # must not be stored in the database. Therefore we cannot simply
+ # use conv_i().
+ my $pricegroup_id = $form->{"pricegroup_id_$i"} * 1;
+ $pricegroup_id = undef if !$pricegroup_id;
+
# save detail record in delivery_order_items table
@values = (conv_i($item_id), conv_i($form->{id}), conv_i($form->{"id_$i"}),
$form->{"description_$i"}, $form->{"longdescription_$i"},
$form->{"lastcost_$i"},
conv_i($form->{"price_factor_id_$i"}), conv_i($form->{"price_factor_id_$i"}),
conv_i($form->{"marge_price_factor_$i"}),
- conv_i($form->{"pricegroup_id_$i"}));
+ $pricegroup_id);
do_statement($form, $h_item, $q_item, @values);
my $stock_info = DO->unpack_stock_information('packed' => $form->{"stock_${in_out}_$i"});
shippingpoint = ?, shipvia = ?, notes = ?, intnotes = ?, closed = ?,
delivered = ?, department_id = ?, language_id = ?, shipto_id = ?,
globalproject_id = ?, employee_id = ?, salesman_id = ?, cp_id = ?, transaction_description = ?,
- is_sales = ?, taxzone_id = ?, taxincluded = ?, terms = ?, curr = ?
+ is_sales = ?, taxzone_id = ?, taxincluded = ?, terms = ?, curr = (SELECT id FROM currencies WHERE curr = ?)
WHERE id = ?|;
@values = ($form->{donumber}, $form->{ordnumber},
d.description AS department, dord.language_id,
dord.shipto_id,
dord.globalproject_id, dord.delivered, dord.transaction_description,
- dord.taxzone_id, dord.taxincluded, dord.terms, dord.curr AS currency
+ dord.taxzone_id, dord.taxincluded, dord.terms, (SELECT cu.curr FROM currencies cu WHERE cu.id=dord.curr) AS currency
FROM delivery_orders dord
JOIN ${vc} cv ON (dord.${vc}_id = cv.id)
LEFT JOIN employee e ON (dord.employee_id = e.id)
}
$sth->finish();
- # remove any trailing whitespace
- $form->{currency} =~ s/\s*$//;
-
$form->{donumber_array} =~ s/\s*$//g;
$form->{saved_donumber} = $form->{donumber};
sub order_details {
$main::lxdebug->enter_sub();
- my ($self) = @_;
-
- my $myconfig = \%main::myconfig;
- my $form = $main::form;
+ my ($self, $myconfig, $form) = @_;
# connect to database
my $dbh = $form->get_standard_dbh($myconfig);
my $ic_cvar_configs = CVar->get_configs(module => 'IC');
$form->{TEMPLATE_ARRAYS} = { };
- IC->prepare_parts_for_printing();
+ IC->prepare_parts_for_printing(myconfig => $myconfig, form => $form);
my @arrays =
qw(runningnumber number description longdescription qty unit
while (my $ref = $h_pg->fetchrow_hashref("NAME_lc")) {
if ($form->{groupitems} && $ref->{partsgroup} ne $sameitem) {
- map({ push(@{ $form->{$_} }, "") } grep({ $_ ne "description" } @arrays));
+ map({ push(@{ $form->{TEMPLATE_ARRAYS}->{$_} }, "") } grep({ $_ ne "description" } @arrays));
$sameitem = ($ref->{partsgroup}) ? $ref->{partsgroup} : "--";
- push(@{ $form->{description} }, $sameitem);
+ push(@{ $form->{TEMPLATE_ARRAYS}->{description} }, $sameitem);
}
- push(@{ $form->{description} }, $form->format_amount($myconfig, $ref->{qty} * $form->{"qty_$i"}) . qq|, $ref->{partnumber}, $ref->{description}|);
+ push(@{ $form->{TEMPLATE_ARRAYS}->{"description"} }, $form->format_amount($myconfig, $ref->{qty} * $form->{"qty_$i"}) . qq| -- $ref->{partnumber}, $ref->{description}|);
- map({ push(@{ $form->{$_} }, "") } grep({ $_ ne "description" } @arrays));
+ map({ push(@{ $form->{TEMPLATE_ARRAYS}->{$_} }, "") } grep({ $_ ne "description" } @arrays));
}
}