use SL::IC;
use SL::IO;
+use SL::DB::Default;
use SL::DB::Language;
use SL::DB::Printer;
use SL::Helper::Flash;
sub _check_io_auth {
$main::auth->assert('part_service_assembly_edit | vendor_invoice_edit | sales_order_edit | invoice_edit |' .
'request_quotation_edit | sales_quotation_edit | purchase_order_edit | ' .
- 'purchase_delivery_order_edit | sales_delivery_order_edit');
+ 'purchase_delivery_order_edit | sales_delivery_order_edit | part_service_assembly_details');
}
########################################
my ($stock_in_out, $stock_in_out_title);
+ my $defaults = AM->get_defaults();
+ $form->{show_weight} = $defaults->{show_weight};
+ $form->{weightunit} = $defaults->{weightunit};
+
my $is_purchase = (first { $_ eq $form->{type} } qw(request_quotation purchase_order purchase_delivery_order)) || ($form->{script} eq 'ir.pl');
my $show_min_order_qty = first { $_ eq $form->{type} } qw(request_quotation purchase_order);
my $is_delivery_order = $form->{type} =~ /_delivery_order$/;
}
# column_index
- my @header_sort = qw(runningnumber partnumber description ship qty unit sellprice_pg sellprice discount linetotal);
+ my @header_sort = qw(runningnumber partnumber description ship qty unit weight sellprice_pg sellprice discount linetotal);
my @HEADER = (
{ id => 'runningnumber', width => 5, value => $locale->text('No.'), display => 1, },
{ id => 'partnumber', width => 8, value => $locale->text('Number'), display => 1, },
{ id => 'qty', width => 5, value => $locale->text('Qty'), display => 1, },
{ id => 'price_factor', width => 5, value => $locale->text('Price Factor'), display => !$is_delivery_order, },
{ id => 'unit', width => 5, value => $locale->text('Unit'), display => 1, },
+ { id => 'weight', width => 5, value => $locale->text('Weight'), display => $defaults->{show_weight}, },
{ id => 'serialnr', width => 10, value => $locale->text('Serial No.'), display => 0, },
{ id => 'projectnr', width => 10, value => $locale->text('Project'), display => 0, },
{ id => 'sellprice', width => 15, value => $locale->text('Price'), display => !$is_delivery_order, },
my $deliverydate = $locale->text('Required by');
# special alignings
- my %align = map { $_ => 'right' } qw(qty ship right sellprice_pg discount linetotal stock_in_out);
+ my %align = map { $_ => 'right' } qw(qty ship right sellprice_pg discount linetotal stock_in_out weight);
my %nowrap = map { $_ => 1 } qw(description unit);
$form->{marge_total} = 0;
$form->{sellprice_total} = 0;
$form->{lastcost_total} = 0;
+ $form->{totalweight} = 0;
my %projectnumber_labels = ();
my @projectnumber_values = ("");
_update_ship() if ($is_s_p_order);
_update_custom_variables();
+ my $totalweight = 0;
+
# rows
my @ROWS;
} else {
$column_data{price_factor} = ' ';
}
+ $form->{"weight_$i"} *= AM->convert_unit($form->{"selected_unit_$i"}, $form->{"partunit_$i"}, $all_units) || 1;
$column_data{"unit"} = AM->unit_select_html($all_units, "unit_$i", $this_unit, $form->{"id_$i"} ? $form->{"unit_$i"} : undef);
# / unit ending
$column_data{linetotal} = $form->format_amount(\%myconfig, $linetotal, 2);
$column_data{bin} = $form->{"bin_$i"};
+ $column_data{weight} = $form->format_amount(\%myconfig, $form->{"qty_$i"} * $form->{"weight_$i"}, 3) . ' ' . $defaults->{weightunit} if $defaults->{show_weight};
+
if ($is_delivery_order) {
$column_data{stock_in_out} = calculate_stock_in_out($i);
}
if $form->{"id_$i"} && ($form->{type} =~ /^sales_/ || $form->{type} =~ /invoice/) ;
# / marge calculations ending
+# Calculate total weight
+ $totalweight += ($form->{"qty_$i"} * $form->{"weight_$i"});
+
# calculate onhand
if ($form->{"id_$i"}) {
my $part = IC->get_basic_part_info(id => $form->{"id_$i"});
map { ($cgi->hidden("-name" => $_, "-value" => $form->{$_})); } map { $_."_$i" }
(qw(orderitems_id bo pricegroup_old price_old id inventory_accno bin partsgroup partnotes
income_accno expense_accno listprice assembly taxaccounts ordnumber transdate cusordnumber
- longdescription basefactor marge_absolut marge_percent marge_price_factor), @hidden_vars)
+ longdescription basefactor marge_absolut marge_percent marge_price_factor weight), @hidden_vars)
);
map { $form->{"${_}_base"} += $linetotal } (split(/ /, $form->{"taxaccounts_$i"}));
push @ROWS, { ROW1 => \@ROW1, ROW2 => \@ROW2, HIDDENS => \@HIDDENS, colspan => $colspan, error => $form->{"row_error_$i"}, };
}
+ $form->{totalweight} = $totalweight;
+
print $form->parse_html_template('oe/sales_order', { ROWS => \@ROWS,
HEADER => \@HEADER,
});
my $attachment_filename = $form->generate_attachment_filename();
my $subject = $form->{subject} || $form->generate_email_subject();
- $::request->{layout}->focus($form->{"email"} ? "#subject" : "#email");
$form->header;
my (@dont_hide_key_list, %dont_hide_key, @hidden_keys);
_check_io_auth();
+ my $defaults = SL::DB::Default->get;
+ $form->error($::locale->text('No print templates have been created for this client yet. Please do so in the client configuration.')) if !$defaults->templates;
+ $form->{templates} = $defaults->templates;
+
my ($old_form) = @_;
my $inv = "inv";
if ($shipto) {
if ( $form->{formname} eq 'purchase_order'
|| $form->{formname} eq 'request_quotation') {
- $form->{shiptoname} = $myconfig{company};
- $form->{shiptostreet} = $myconfig{address};
+ $form->{shiptoname} = $defaults->company;
+ $form->{shiptostreet} = $defaults->address;
} else {
map { $form->{"shipto$_"} = $form->{$_} } @a;
}
$form->{notes} =~ s/^\s+//g;
- $form->{templates} = "$myconfig{templates}";
-
delete $form->{printer_command};
$form->{language} = $form->get_template_language(\%myconfig);
push @template_files, "$form->{formname}.$extension";
push @template_files, "default.$extension";
@template_files = uniq @template_files;
- $form->{IN} = first { -f "$myconfig{templates}/$_" } @template_files;
+ $form->{IN} = first { -f ($defaults->templates . "/$_") } @template_files;
if (!defined $form->{IN}) {
$::form->error($::locale->text('Cannot find matching template for this print request. Please contact your template maintainer. I tried these: #1.', join ', ', map { "'$_'"} @template_files));
my $info = $form->{PART_INFORMATION}->{$form->{"id_${i}"}} || { };
$form->{"partunit_${i}"} = $info->{unit};
+ $form->{"weight_$i"} = $info->{weight};
}
$main::lxdebug->leave_sub();