X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fio.pl;h=5af1b88174fec51c9f09db328f246d58788ae446;hb=273b5e046f1dab732ece657a756ada58d7669b9d;hp=0d7601ea6f9dd52539bd1f827454021894e00ae9;hpb=66f2badbfcb03c16bf19c3dd2439e1a7264a768c;p=kivitendo-erp.git diff --git a/bin/mozilla/io.pl b/bin/mozilla/io.pl index 0d7601ea6..5af1b8817 100644 --- a/bin/mozilla/io.pl +++ b/bin/mozilla/io.pl @@ -47,8 +47,12 @@ use SL::CT; use SL::IC; use SL::IO; +use SL::DB::Customer; +use SL::DB::Default; use SL::DB::Language; use SL::DB::Printer; +use SL::DB::Vendor; +use SL::Helper::CreatePDF; use SL::Helper::Flash; require "bin/mozilla/common.pl"; @@ -102,7 +106,7 @@ use Data::Dumper; 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'); } ######################################## @@ -123,6 +127,10 @@ sub display_row { 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$/; @@ -141,7 +149,7 @@ sub display_row { } # 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, }, @@ -150,6 +158,7 @@ sub display_row { { 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, }, @@ -187,12 +196,13 @@ sub display_row { 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 = (""); @@ -205,6 +215,8 @@ sub display_row { _update_ship() if ($is_s_p_order); _update_custom_variables(); + my $totalweight = 0; + # rows my @ROWS; @@ -216,6 +228,10 @@ sub display_row { qw(qty discount sellprice lastcost price_new price_old) unless ($form->{simple_save}); + if ($form->{"prices_$i"} && ($form->{"new_pricegroup_$i"} != $form->{"old_pricegroup_$i"})) { + $form->{"sellprice_$i"} = $form->{"price_new_$i"}; + } + # unit begin $form->{"unit_old_$i"} ||= $form->{"unit_$i"}; $form->{"selected_unit_$i"} ||= $form->{"unit_$i"}; @@ -246,6 +262,7 @@ sub display_row { } 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 @@ -260,12 +277,17 @@ sub display_row { my $linetotal = $form->round_amount($form->{"qty_$i"} * $form->{"sellprice_$i"} * (100 - $form->{"discount_$i"}) / 100 / $price_factor, 2); my $rows = $form->numtextrows($form->{"description_$i"}, 30, 6); - $column_data{runningnumber} = $cgi->textfield(-name => "runningnumber_$i", -size => 5, -value => $i); # HuT - $column_data{partnumber} = $cgi->textfield(-name => "partnumber_$i", -size => 12, -value => $form->{"partnumber_$i"}); + # quick delete single row + $column_data{runningnumber} .= q|| . + q|| . $locale->text('Remove') . q| |; + $column_data{runningnumber} .= $cgi->textfield(-name => "runningnumber_$i", -id => "runningnumber_$i", -size => 5, -value => $i); # HuT + + + $column_data{partnumber} = $cgi->textfield(-name => "partnumber_$i", -id => "partnumber_$i", -size => 12, -value => $form->{"partnumber_$i"}); $column_data{description} = (($rows > 1) # if description is too large, use a textbox instead - ? $cgi->textarea( -name => "description_$i", -default => $form->{"description_$i"}, -rows => $rows, -columns => 30) - : $cgi->textfield(-name => "description_$i", -size => 30, -value => $form->{"description_$i"})) - . $cgi->button(-value => $locale->text('L'), -onClick => "set_longdescription_window('longdescription_$i')"); + ? $cgi->textarea( -name => "description_$i", -id => "description_$i", -default => $form->{"description_$i"}, -rows => $rows, -columns => 30) + : $cgi->textfield(-name => "description_$i", -id => "description_$i", -value => $form->{"description_$i"}, -size => 30)) + . $cgi->button(-value => $locale->text('L'), -onClick => "kivi.SalesPurchase.edit_longdescription($i)"); my $qty_dec = ($form->{"qty_$i"} =~ /\.(\d+)/) ? length $1 : 2; @@ -325,6 +347,8 @@ sub display_row { $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); } @@ -389,6 +413,9 @@ sub display_row { 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"}); @@ -406,17 +433,19 @@ sub display_row { if ($is_delivery_order) { map { $form->{"${_}_${i}"} = $form->format_amount(\%myconfig, $form->{"${_}_${i}"}) } qw(sellprice discount lastcost); - push @hidden_vars, qw(sellprice discount not_discountable price_factor_id lastcost pricegroup_id); + $form->{"pricegroup_id_$i"} = $form->{"pricegroup_old_$i"} if $form->{"pricegroup_old_$i"}; + $form->{"sellprice_pg_$i"} = $form->{"hidden_prices_$i"} if $form->{"hidden_prices_$i"}; + push @hidden_vars, grep { defined $form->{"${_}_${i}"} } qw(sellprice discount not_discountable price_factor_id lastcost pricegroup_id sellprice_pg); push @hidden_vars, "stock_${stock_in_out}_sum_qty", "stock_${stock_in_out}"; } my @HIDDENS = map { value => $_}, ( $cgi->hidden("-name" => "unit_old_$i", "-value" => $form->{"selected_unit_$i"}), $cgi->hidden("-name" => "price_new_$i", "-value" => $form->format_amount(\%myconfig, $form->{"price_new_$i"})), - map { ($cgi->hidden("-name" => $_, "-value" => $form->{$_})); } map { $_."_$i" } + map { ($cgi->hidden("-name" => $_, "-id" => $_, "-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) + income_accno expense_accno listprice assembly taxaccounts ordnumber donumber transdate cusordnumber + longdescription basefactor marge_absolut marge_percent marge_price_factor weight), @hidden_vars) ); map { $form->{"${_}_base"} += $linetotal } (split(/ /, $form->{"taxaccounts_$i"})); @@ -429,6 +458,8 @@ sub display_row { 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, }); @@ -466,6 +497,10 @@ sub set_pricegroup { $form->{"sellprice_$j"} = $item->{price} if $item->{selected} && $item->{pricegroup_id}; $form->{"price_new_$j"} = $form->{"sellprice_$j"} if $item->{selected} || !$item->{pricegroup_id}; } + + # save hidden pricegroups for delivery_orders + next unless my @selected_prices = grep { $_->{selected} } @{ $form->{PRICES}{$j} }; + $form->{"hidden_prices_$j"} = $selected_prices[-1]{price} . "--" . $selected_prices[-1]{pricegroup_id}; } $main::lxdebug->leave_sub(); } @@ -571,7 +606,6 @@ sub item_selected { map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) } qw(sellprice listprice weight); - $form->{sellprice} += ($form->{"sellprice_$i"} * $form->{"qty_$i"}); $form->{weight} += ($form->{"weight_$i"} * $form->{"qty_$i"}); if ($form->{"not_discountable_$i"}) { @@ -653,11 +687,7 @@ sub check_form { my $count = 0; # remove any makes or model rows - if ($form->{item} eq 'part') { - map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) } - qw(listprice sellprice lastcost weight rop); - - } elsif ($form->{item} eq 'assembly') { + if ($form->{item} eq 'assembly') { # fuer assemblies auskommentiert. seiteneffekte? ;-) wird die woanders benoetigt? #$form->{sellprice} = 0; @@ -690,10 +720,7 @@ sub check_form { $form->redo_rows(\@flds, \@a, $count, $form->{assembly_rows}); $form->{assembly_rows} = $count; - } elsif ($form->{item} eq 'service') { - map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) } qw(listprice sellprice lastcost); - - } else { + } elsif ($form->{item} !~ m{^(?:part|service)$}) { remove_emptied_rows(1); $form->{creditremaining} -= &invoicetotal; @@ -730,7 +757,7 @@ sub remove_emptied_rows { taxaccounts bin assembly weight projectnumber project_id oldprojectnumber runningnumber serialnumber partsgroup payment_id not_discountable shop ve gv buchungsgruppen_id language_values - sellprice_pg pricegroup_old price_old price_new unit_old ordnumber + sellprice_pg pricegroup_old price_old price_new unit_old ordnumber donumber transdate longdescription basefactor marge_total marge_percent marge_price_factor lastcost price_factor_id partnotes stock_out stock_in has_sernumber reqdate); @@ -849,8 +876,6 @@ sub order { } $form->{script} = 'oe.pl'; - $form->{shipto} = 1; - $form->{rowcount}--; $form->{cp_id} *= 1; @@ -915,8 +940,6 @@ sub quotation { $form->{script} = 'oe.pl'; - $form->{shipto} = 1; - $form->{rowcount}--; require "bin/mozilla/$form->{script}"; @@ -935,7 +958,7 @@ sub quotation { map({ $form->{"${_}_${i}"} = $form->parse_amount(\%myconfig, $form->{"${_}_${i}"}) if ($form->{"${_}_${i}"}) } - qw(ship qty sellprice listprice basefactor discount)); + qw(ship qty sellprice listprice basefactor discount lastcost)); } &prepare_order; @@ -977,10 +1000,13 @@ sub edit_e_mail { $form->{oldmedia} = $form->{media}; $form->{media} = "email"; + my $global_bcc = AM->get_defaults()->{global_bcc}; + + $form->{bcc} = join ', ', grep $_, $form->{bcc}, $global_bcc; + 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); @@ -1209,7 +1235,11 @@ sub print_form { _check_io_auth(); - my ($old_form) = @_; + 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, %params) = @_; my $inv = "inv"; my $due = "due"; @@ -1305,6 +1335,14 @@ sub print_form { $form->{label} = $form->{formname} eq 'pick_list' ? $locale->text('Pick List') : $locale->text('Delivery Order'); } + $form->{TEMPLATE_DRIVER_OPTIONS} = { }; + if (any { $form->{type} eq $_ } qw(sales_quotation sales_order sales_delivery_order invoice request_quotation purchase_order purchase_delivery_order)) { + $form->{TEMPLATE_DRIVER_OPTIONS}->{variable_content_types} = { + longdescription => 'html', + partnotes => 'html', + }; + } + $form->isblank("email", $locale->text('E-mail address missing!')) if ($form->{media} eq 'email'); $form->isblank("${inv}date", @@ -1319,31 +1357,7 @@ sub print_form { # $locale->text('Quotation Number missing!') # $locale->text('Quotation Date missing!') - # assign number $form->{what_done} = $form->{formname}; - if (!$form->{"${inv}number"} && !$form->{preview} && !$form->{id}) { - $form->{"${inv}number"} = $form->update_defaults(\%myconfig, $numberfld); - if ($form->{media} ne 'email') { - - # get pricegroups for parts - IS->get_pricegroups_for_parts(\%myconfig, \%$form); - - # build up html code for prices_$i - set_pricegroup($form->{rowcount}); - - $form->{rowcount}--; - - call_sub($display_form); - # saving the history - if(!exists $form->{addition}) { - $form->{snumbers} = qq|ordnumber_| . $form->{ordnumber}; - $form->{addition} = "PRINTED"; - $form->save_history; - } - # /saving the history - ::end_of_request(); - } - } &validate_items; @@ -1353,6 +1367,7 @@ sub print_form { my $language_saved = $form->{language_id}; my $payment_id_saved = $form->{payment_id}; + my $delivery_term_id_saved = $form->{delivery_term_id}; my $salesman_id_saved = $form->{salesman_id}; my $cp_id_saved = $form->{cp_id}; my $taxzone_id_saved = $form->{taxzone_id}; @@ -1362,6 +1377,7 @@ sub print_form { $form->{language_id} = $language_saved; $form->{payment_id} = $payment_id_saved; + $form->{delivery_term_id} = $delivery_term_id_saved; $form->{taxzone_id} = $taxzone_id_saved; $form->{currency} = $currency_saved; @@ -1394,7 +1410,7 @@ sub print_form { # create the form variables if ($form->{type} =~ /_delivery_order$/) { - DO->order_details(); + DO->order_details(\%myconfig, \%$form); } elsif ($order) { OE->order_details(\%myconfig, \%$form); } else { @@ -1408,32 +1424,8 @@ sub print_form { $form->get_shipto(\%myconfig); } - my @a = qw(name department_1 department_2 street zipcode city country contact phone fax email); - - my $shipto = 1; - - # if there is no shipto fill it in from billto - foreach my $item (@a) { - if ($form->{"shipto$item"}) { - $shipto = 0; - last; - } - } - - if ($shipto) { - if ( $form->{formname} eq 'purchase_order' - || $form->{formname} eq 'request_quotation') { - $form->{shiptoname} = $myconfig{company}; - $form->{shiptostreet} = $myconfig{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); @@ -1507,18 +1499,20 @@ sub print_form { } # search for the template - my @template_files; - push @template_files, "$form->{formname}_email$form->{language}$printer_code.$extension" if $form->{media} eq 'email'; - push @template_files, "$form->{formname}$form->{language}$printer_code.$extension"; - push @template_files, "$form->{formname}.$extension"; - push @template_files, "default.$extension"; - @template_files = uniq @template_files; - $form->{IN} = first { -f "$myconfig{templates}/$_" } @template_files; - - if (!defined $form->{IN}) { + my ($template_file, @template_files) = SL::Helper::CreatePDF->find_template( + name => $form->{formname}, + email => $form->{media} eq 'email', + language_id => $form->{language_id}, + printer_id => $form->{printer_id}, + extension => $extension, + ); + + if (!defined $template_file) { $::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)); } + $form->{IN} = $template_file; + delete $form->{OUT}; if ($form->{media} eq 'printer') { @@ -1577,7 +1571,7 @@ sub print_form { # saving the history if(!exists $form->{addition}) { - $form->{snumbers} = qq|ordnumber_| . $form->{ordnumber}; + $form->{snumbers} = "${inv}number" . "_" . $form->{"${inv}number"}; if($form->{media} =~ /printer/) { $form->{addition} = "PRINTED"; } @@ -1597,11 +1591,11 @@ sub print_form { # prepare meta information for template introspection $form->{template_meta} = { formname => $form->{formname}, - language => SL::DB::Manager::Language->find_by_or_create(id => $form->{language_id}), + language => SL::DB::Manager::Language->find_by_or_create(id => $form->{language_id} || undef), format => $form->{format}, media => $form->{media}, extension => $extension, - printer => SL::DB::Manager::Printer->find_by_or_create(id => $form->{printer_id}), + printer => SL::DB::Manager::Printer->find_by_or_create(id => $form->{printer_id} || undef), today => DateTime->today, }; @@ -1653,7 +1647,10 @@ sub print_form { ($form->{media} eq 'printer') ? $locale->text('sent to printer') : $locale->text('emailed to') . " $form->{email}"; - $form->redirect(qq|$form->{label} $form->{"${inv}number"} $msg|); + + if (!$params{no_redirect}) { + $form->redirect(qq|$form->{label} $form->{"${inv}number"} $msg|); + } } if ($form->{printing}) { call_sub($display_form); @@ -1727,8 +1724,11 @@ sub ship_to { $::form->{title} = $::locale->text('Ship to'); $::form->header; + my $vc_obj = ($::form->{vc} eq 'customer' ? "SL::DB::Customer" : "SL::DB::Vendor")->new(id => $::form->{$::form->{vc} . "_id"})->load; + print $::form->parse_html_template('io/ship_to', { previousform => $previous_form, nextsub => $::form->{display_form} || 'display_form', + vc_obj => $vc_obj, }); $main::lxdebug->leave_sub(); @@ -1770,7 +1770,7 @@ sub set_duedate { my $invdate = $form->{invdate} eq 'undefined' ? undef : $form->{invdate}; my $duedate = $form->get_duedate(\%myconfig, $invdate); - print $form->ajax_response_header() . $duedate; + print $form->ajax_response_header() . ($duedate || $invdate); $main::lxdebug->leave_sub(); } @@ -1790,6 +1790,7 @@ sub _update_part_information { my $info = $form->{PART_INFORMATION}->{$form->{"id_${i}"}} || { }; $form->{"partunit_${i}"} = $info->{unit}; + $form->{"weight_$i"} = $info->{weight}; } $main::lxdebug->leave_sub(); @@ -1869,32 +1870,92 @@ sub _render_custom_variables_inputs { my $valid = CVar->custom_variables_validity_by_trans_id(trans_id => $params{part_id}); + # get partsgroup_id from part + my $partsgroup_id; + if ($params{part_id}) { + $partsgroup_id = SL::DB::Part->new(id => $params{part_id})->load->partsgroup_id; + } + my $num_visible_cvars = 0; foreach my $cvar (@{ $form->{CVAR_CONFIGS}->{IC} }) { $cvar->{valid} = $params{part_id} && $valid->($cvar->{id}); + # set partsgroup filter + my $partsgroup_filtered = 0; + if ($cvar->{flag_partsgroup_filter}) { + if (!$partsgroup_id || (!grep {$partsgroup_id == $_} @{ $cvar->{partsgroups} })) { + $partsgroup_filtered = 1; + } + } + + my $hide_non_editable = 1; + + my $show = 0; my $description = ''; - if ($cvar->{flag_editable} && $cvar->{valid}) { + if (( ($cvar->{flag_editable} || !$hide_non_editable) && $cvar->{valid}) && !$partsgroup_filtered) { $num_visible_cvars++; $description = $cvar->{description} . ' '; + $show = 1; } my $form_key = "ic_cvar_" . $cvar->{name} . "_$params{row}"; push @{ $params{ROW2} }, { - line_break => $num_visible_cvars == 1, + line_break => $show && !(($num_visible_cvars - 1) % ($::myconfig{form_cvars_nr_cols}*1 || 3)), description => $description, cvar => 1, render_options => { - hide_non_editable => 1, + hide_non_editable => $hide_non_editable, var => $cvar, name_prefix => 'ic_', name_postfix => "_$params{row}", valid => $cvar->{valid}, value => CVar->parse($::form->{$form_key}, $cvar), + partsgroup_filtered => $partsgroup_filtered, } }; } $main::lxdebug->leave_sub(2); } + +sub _remove_billed_or_delivered_rows { + my (%params) = @_; + + croak "Missing parameter 'quantities'" if !$params{quantities}; + + my @fields = map { s/_1$//; $_ } grep { m/_1$/ } keys %{ $::form }; + my @new_rows; + + my $make_key = sub { + my ($row) = @_; + return $::form->{"id_${row}"} unless $::form->{"serialnumber_${row}"}; + my $key = $::form->{"id_${row}"} . ':' . $::form->{"serialnumber_${row}"}; + return exists $params{quantities}->{$key} ? $key : $::form->{"id_${row}"}; + }; + + my $removed_rows = 0; + my $row = 0; + while ($row < $::form->{rowcount}) { + $row++; + next unless $::form->{"id_$row"}; + + my $parts_id = $::form->{"id_$row"}; + my $base_qty = $::form->parse_amount(\%::myconfig, $::form->{"qty_$row"}) * SL::DB::Manager::Unit->find_by(name => $::form->{"unit_$row"})->base_factor; + + my $key = $make_key->($row); + my $sub_qty = min($base_qty, $params{quantities}->{$key}); + $params{quantities}->{$key} -= $sub_qty; + + if (!$sub_qty || ($sub_qty != $base_qty)) { + $::form->{"qty_${row}"} = $::form->format_amount(\%::myconfig, ($base_qty - $sub_qty) / SL::DB::Manager::Unit->find_by(name => $::form->{"unit_$row"})->base_factor); + push @new_rows, { map { $_ => $::form->{"${_}_${row}"} } @fields }; + + } else { + $removed_rows++; + } + } + + $::form->redo_rows(\@fields, \@new_rows, scalar(@new_rows), $::form->{rowcount}); + $::form->{rowcount} -= $removed_rows; +}