%# The nice thing about standards is that there are so many of them to %# choose from. -- Andrew S. Tanenbaum <& /Edit/Elements/104Header, Buttons => [ Add => ( $session{CurrentUser}->HasRight( Right => 'CreateReport', Object => $RTx::Reports ) ? "/RG/Report/index.html?Action-Add=1" : ''), Save => ($Disabled ? '' : $hasRight->('SaveReport') ? "javascript:document.getElementById('mainform').submit()" : ''), Delete => '', Copy => '', Search => '', Lot => '', Count => '', Check => '', Import => ( $hasRight->('ImportReport') ? $m->scomp('/Edit/Elements/NewWindow', "Import.html", 650, 290) : ''), Export => ( $hasRight->('ExportReport') ? "/RG/Report/View.html/report.xml?View=XML" : ''), TransIn => '', TransOut => '', Info => '', Report => '', Help => '1', ], Method => 'POST', BGColor => '#ADD6D6', Top =>'/RG/Elements/Top', &>

<& /RG/Elements/Tab, Text => 'Report Edit' &>
<& Info, Id => $Id, ReportObj => $ReportObj, Disabled => $Disabled &> % if ( eval { $ReportObj->HandleObj->dbh->ping } ) { % } else { <&|/l&>Please select a data source and click 'Save' first. % }

<%INIT> our $DB; $Id = 0 if $Action eq 'Add'; $session{changed} = 0; $session{reportId} = $Id; my $ReportObj = $DB->ReportObj($Id) if $Id; if ($Action eq 'Import') { } elsif ($Action eq 'Save') { if (!$ReportObj) { $ReportObj = RTx::Report->new($session{CurrentUser}); $ReportObj->Create( Owner => $session{CurrentUser}->UserObj->Id ); } foreach my $key (map "report$_", $ReportObj->Keys) { my $method = "Set" . substr($key, 6); $session{$key} = $ARGS{$key} if defined($ARGS{$key}); $ReportObj->$method( $session{$key} ); } $session{"reportId"} = $Id = $ReportObj->Id; } elsif ( $ReportObj ) { $session{reportSectionId} = 0; $session{reportPartId} = 0; $session{reportClauseId} = 0; $session{"report$_"} = $ReportObj->$_ for $ReportObj->Keys; my $ContentObj = DBIx::ReportBuilder->new( Handle => $ReportObj->HandleObj, SearchHook => $ReportObj->SearchHook, Content => $session{reportContent}, Loc => \&loc, ); $ContentObj->VarObj->Reload; $session{"reportContent"} = $ContentObj->RenderXML; } else { $session{"report$_"} = '' for RTx::Report->Keys; $session{"reportAuthor"} = $session{CurrentUser}->UserObj->Name; $session{"reportContent"} = RTx::Report->NewContent; } $session{"reportView"} ||= $View; my $Disabled = ''; $Disabled = 'disabled' if $Id and $session{'reportLocked'} and $session{'reportAuthor'} ne $session{CurrentUser}->UserObj->Name; my $hasRight = sub { !$ReportObj or $ReportObj->CurrentUserHasRight($_[0]) }; <%ARGS> $View => 'Edit' $Action => undef $Id => $session{"reportId"}