[L]Table[/L] [page href="@@MM_BASE@@/dbedit" arg="[value mv_data_table]"][value mv_data_table]</A>

[if session arg] [value name="mvc_data_table" set="[data session arg]" scratch=1 hide=1] [value name="mv_data_table" set="[value mvc_data_table]" hide=1] [/if] [if-mm !tables] [bounce page="@@MM_BASE@@/violation"] [/if-mm] [if-mm !advanced report] [bounce page="@@MM_BASE@@/violation"] [/if-mm] [calc] $Config->{NoSearch} = ''; [/calc] [perl] $Scratch->{relocate} = ''; return unless $CGI->{row_change}; $CGI->{row_change} =~ /^(insert|append|delete)(\d+)$/ or return; $function = $1; $row = $2; %saved = %$CGI; for(keys %saved) { push @del, $_ unless length($saved{$_}); } for(@del) { delete $saved{$_}; } @del = (); my @change; my %ignore = qw/ break sort_order sort_option /; my $key; my $max = 0; foreach $key (keys %saved) { next unless $key =~ /^(\w+\D)(\d+)$/; my $nm = $1; my $idx = $2; next if $ignore{$nm}; $max = $idx if $idx > $max and $key eq "table$idx"; if($function eq 'append') { next if $idx <= $row; } else { next if $idx < $row; } push @change, [$key, $saved{$key}]; push @del, $key; } for(@del) { delete $saved{$_}; } if($function eq 'insert' or $function eq 'append') { $max++; for(@change) { my ($k, $v) = @{$_}; $k =~ s/(\d+)$/$1 + 1/e; $saved{$k} = $v; } $Scratch->{relocate} = '@@MM_BASE@@/report'; } elsif($function eq 'delete') { $max--; for(@change) { my ($k, $v) = @{$_}; $k =~ /(\d+)/; my $idx = $1; next if $idx == $row; $k =~ s/(\d+)$/$1 - 1/e; $saved{$k} = $v; } $Scratch->{relocate} = '@@MM_BASE@@/report'; } else { $Scratch->{relocate} = 'special/failed'; } $saved{num_columns} = $max > 1 ? $max + 1 : 3; $Values->{saved_report} = \%saved; return; [/perl] [if scratch relocate] [bounce href="[area href=`$Scratch->{relocate}`]"] [/if]
[seti name=tables][list-databases][/seti] [perl table="[scratch tables]"] $vals = {}; my $current_table = $Values->{mv_data_table} = $CGI->{report_table}; %saved = %$CGI; for(keys %saved) { push @del, $_ unless length($saved{$_}); } for(@del) { delete $saved{$_}; } unless ($current_table) { $Scratch->{search_string} = ""; $Scratch->{search_page} = "
NO CURRENT TABLE
"; return; } my $large = $Db{$current_table}->config('LARGE'); for( keys %{$CGI} ) { next unless /^([A-Za-z_]+)(\d+)$/; my $item = $1; my $idx = $2; $vals->{$item} = [] unless defined $vals->{$item}; $vals->{$item}[$idx] = $CGI->{"$item$idx"}; } return "No tables/columns selected" unless defined $vals->{table}; if($CGI->{search_field} and $CGI->{search_spec}) { push @string, "co=1"; push @string, "se=$CGI->{search_spec}"; push @string, "sf=$CGI->{search_field}"; push @string, "op=$CGI->{search_op}"; push @string, "nu=1" if $CGI->{search_op} =~ /\W/; } else { push @string, "ra=yes"; } push @string, "st=db" unless $large; push @string, "fi=$current_table"; if ($CGI->{matchlimit}) { push @string, "ml=$CGI->{matchlimit}"; my $page = $CGI->{report_title}; $page =~ s/%/%37/g; push @string, "sp=@@MM_BASE@@/reports/$page"; } else { push @string, "ml=999999"; } if($vals->{sort_order}) { for(my $i = 0; $i < scalar @{$vals->{sort_order}}; $i++) { my $f = $vals->{sort_order}[$i]; last unless $f; push @string, "tf=$f"; push @string, "to=" . $vals->{sort_option}[$i]; if($vals->{break}[$i]) { unshift(@breaks, $f); $hfoot_change{$f} = qq{\n[item-change $i][condition]}; $hfoot_change{$f} .= qq{[item-data $current_table $f]}; $hfoot_change{$f} .= qq{[/condition]\n}; $foot_change{$f} = qq{
\n}; $efoot_change{$f} = "[/item-change $i]\n"; } } } my $header = "
\n"; my $page = ''; my $summary_found; $page .= "
\n" unless $summary_only; my $end_line = ''; my $total_line = "
\n"; my $count = 0; for (my $i = 0; $i < 10; $i++) { last if ! $vals->{table}[$i]; $count++; } $saved{num_columns} = $count; $Values->{saved_report} = \%saved; for (my $i = 0; $i < $count; $i++) { my $t = $vals->{table}[$i] or last; my $c = $vals->{column}[$i]; my $k = $vals->{key}[$i]; my $h = $vals->{heading}[$i] || $c; my $s = $vals->{summary}[$i]; my $r = $vals->{filter}[$i]; my $e = $vals->{edit}[$i]; my $ek = $vals->{editkey}[$i] || ''; if($r) { $r =~ s/'/\\'/g; $r =~ s/[\0 ]+/' '/g if $r; $r = "'$r'"; } my $l = "ALIGN=$vals->{align}[$i]"; $header .= "\t $h \n"; my $data; if($k) { $data = "[data table=$t column=$c key='[item-data $current_table $k]']"; } else { $data = "[item-data $t $c]"; } if($e) { $ek = $ek ? "[item-data $t $ek]" : $data; } unless($summary_only) { $page .= "\t "; $page .= qq{[page href="@@MM_BASE@@/edit_record" form=" mv_action=return mv_data_table=$e mv_arg=$ek "]} if $e; $page .= qq{[filter op=|$r| interpolate=1]} if $r; $page .= $data; $page .= "[/filter]" if $r; $page .= qq{} if $e; } $total_line .= "\t "; $total_line .= "TOTAL" unless $i; for (@breaks) { $foot_change{$_} .= "\t "; if($_ eq $c) { $foot_change{$_} .= "[if scratch first_done_$c]

[value prev_data_$c]

[/if]"; } elsif($s) { $foot_change{$_} .= qq{[if scratch first_done_$_]}; $foot_change{$_} .= qq{

}; $foot_change{$_} .= qq{[filter op=|$r| interpolate=1]} if $r; $foot_change{$_} .= qq{[summary name=subtotal.$t.$c.$_ total=1]}; $foot_change{$_} .= qq{[summary name=subtotal.$t.$c.$_ reset=1]}; $foot_change{$_} .= qq{[/filter]} if $r; $foot_change{$_} .= qq{

[/if]}; } $foot_change{$_} .= " \n"; } if($s) { $summary_found = 1; $page .= qq{[summary name=total.$t.$c hide=1 amount="$data"]}; for(@breaks) { $page .= qq{[summary name=subtotal.$t.$c.$_ hide=1 amount="$data"]} } $total_line .= qq{}; $total_line .= qq{[filter op=|$r| interpolate=1]} if $r; $total_line .= qq{[summary name=total.$t.$c total=1]\n}; $total_line .= qq{[/filter]} if $r; $total_line .= qq{}; } $total_line .= " \n"; $page .= " \n" unless $summary_only; } $page .= "
\n" unless $summary_only; $header .= "\n"; $total_line .= "\n"; $Scratch->{search_string} = join "\n\t\t", '', @string, ''; $Scratch->{search_page} = scalar(@breaks) ? '' : $header; for (reverse @breaks) { $Scratch->{search_page} .= "[set first_done_$_][/set]\n"; $foot_change{$_} .= ""; $efoot_change{$_} = "\n$header\n$efoot_change{$_}\n"; $header = ''; } $Scratch->{search_page} .= "[search-list]\n"; for (@breaks) { $Scratch->{search_page} .= $hfoot_change{$_}; $Scratch->{search_page} .= $foot_change{$_}; $Scratch->{search_page} .= $efoot_change{$_}; $Scratch->{search_page} .= "\n[set first_done_$_]1[/set]\n"; } $Scratch->{search_page} .= $page; for (@breaks) { $Scratch->{search_page} .= qq{[value name=prev_data_$_ hide=1 set=|}; $Scratch->{search_page} .= qq{[item-data $current_table $_]}; $Scratch->{search_page} .= qq{|]}; } $Scratch->{search_page} .= "\n[/search-list]\n"; for (@breaks) { $Scratch->{search_page} .= $foot_change{$_}; } $Scratch->{search_page} .= $total_line if $summary_found; if($CGI->{matchlimit}) { $Scratch->{search_page} .= "

"; $count--; $Scratch->{search_page} .= < More [more] [/more-list] EOF } return; [/perl]
[comment]

    string: [scratch search_string]
    page: [scratch search_page]

[/comment] [title-bar size=2][page index]__COMPANY__[/page][/title-bar] [title-bar][L]Table[/L] [value mv_data_table] [/title-bar] [if cgi generate_page] [set write_report] [seti name=tables][list-databases][/seti] success=[perl table="[scratch tables]"] my $data = $CGI->{page}; $data =~ s/[/[/g; $data =~ s/\r//g; my $page = $CGI->{report_name}; return 0 unless ($page and $data); $CGI->{definition} =~ s/\r//g; $def = '['; $def .= <{saved_report} = $CGI->{definition}; return; EOF $def .= '['; $def .= '/perl]'; $def .= "[bounce href='[area @@MM_BASE@@/report]']\n"; $page =~ s/([^-\w.])/sprintf '%%%02x', ord($1)/ge; if($Tag->if_mm('super')) { $save_dir = ''; } else { $save_dir = "/user/$Session->{mm_username}"; } $status = $Tag->write_relative_file("pages/config$save_dir/report_def/$page.html", $def); $status &&= $Tag->write_relative_file("pages/config$save_dir/reports/$page.html", $data); delete $CGI->{page}; delete $CGI->{def}; return $status; [/perl] [/set] Report name:
<HTML> <HEAD> <TITLE>[cgi report_title]</TITLE> </HEAD> <BODY> <H1>[cgi report_title]</H1> <TABLE> [set first_done][/set] [search-region more=1 search="[scratch search_string]"] [scratch search_page] [/search-region] </TABLE> [perl] my $val = $Tag->uneval({ ref => $Values->{saved_report} }); $val =~ s/([{,])(')/$1\n$2/g; return $val; [/perl]

[else]

# [cgi report_title]

[search-region search="[scratch search_string]" interpolate=1] [scratch search_page] [/search-region]

[/else] [/if] [set search_page][/set] [set search_string][/set]