added zip archive and in/out board assets

This commit is contained in:
JT Smith 2005-11-19 20:54:15 +00:00
parent 57eaa1f73f
commit cb4729f7e7
15 changed files with 1674 additions and 34 deletions

View file

@ -0,0 +1,312 @@
package WebGUI::Asset::File::ZipArchive;
=head1 LEGAL
-------------------------------------------------------------------
WebGUI is Copyright 2001-2005 Plain Black Corporation.
-------------------------------------------------------------------
Please read the legal notices (docs/legal.txt) and the license
(docs/license.txt) that came with this distribution before using
this software.
-------------------------------------------------------------------
http://www.plainblack.com info@plainblack.com
-------------------------------------------------------------------
=cut
use strict;
use WebGUI::Asset::File;
use WebGUI::HTMLForm;
use WebGUI::HTTP;
use WebGUI::Session;
use WebGUI::SQL;
use WebGUI::Utility;
use Archive::Tar;
use Archive::Zip;
our @ISA = qw(WebGUI::Asset::File);
=head1 NAME
Package WebGUI::Asset::ZipArchive
=head1 DESCRIPTION
Provides a mechanism to upload and automatically extract a zip archive
containing related items. An asset setting will set the launch point of the archive.
=head1 SYNOPSIS
use WebGUI::Asset::ZipArchive;
=head1 METHODS
These methods are available from this class:
=cut
#-------------------------------------------------------------------
sub unzip {
my $self = shift;
my $storage = $_[0];
my $filename = $_[1];
my $filepath = $storage->getPath();
chdir $filepath;
if($filename =~ m/\.zip/i){
my $zip = Archive::Zip->new();
unless ($zip->read($filename) == $zip->AZ_OK){
WebGUI::ErrorHandler::warn(WebGUI::International::get("zip_error","Asset_ZipArchive"));
return 0;
}
$zip->extractTree();
} elsif($filename =~ m/\.tar/i){
Archive::Tar->extract_archive($filepath.$session{os}{slash}.$filename,1);
if (Archive::Tar->error){
WebGUI::ErrorHandler::warn(Archive::Tar->error);
return 0;
}
} else{
WebGUI::ErrorHandler::warn(WebGUI::International::get("bad_archive","Asset_ZipArchive"));
}
return 1;
}
#-------------------------------------------------------------------
=head2 addRevision
This method exists for demonstration purposes only. The superclass
handles revisions to ZipArchive Assets.
=cut
sub addRevision {
my $self = shift;
my $newSelf = $self->SUPER::addRevision(@_);
return $newSelf;
}
#-------------------------------------------------------------------
=head2 definition ( definition )
Defines the properties of this asset.
=head3 definition
A hash reference passed in from a subclass definition.
=cut
sub definition {
my $class = shift;
my $definition = shift;
push(@{$definition}, {
assetName=>WebGUI::International::get('asset label',"Asset_ZipArchive"),
tableName=>'ZipArchiveAsset',
className=>'WebGUI::Asset::File',
properties=>{
showPage=>{
fieldType=>'text',
defaultValue=>'index.html'
},
templateId=>{
fieldType=>'template',
defaultValue=>''
},
}
});
return $class->SUPER::definition($definition);
}
#-------------------------------------------------------------------
=head2 duplicate
This method exists for demonstration purposes only. The superclass
handles duplicating ZipArchive Assets. This method will be called
whenever a copy action is executed
=cut
sub duplicate {
my $self = shift;
my $newAsset = $self->SUPER::duplicate(shift);
return $newAsset;
}
#-------------------------------------------------------------------
=head2 getEditForm ()
Returns the TabForm object that will be used in generating the edit page for this asset.
=cut
sub getEditForm {
my $self = shift;
my $tabform = $self->SUPER::getEditForm();
$tabform->getTab("display")->template(
-value=>$self->getValue("templateId"),
-label=>WebGUI::International::get('template label', 'Asset_ZipArchive'),
-namespace=>"ZipArchiveAsset"
);
$tabform->getTab("properties")->text (
-name=>"showPage",
-label=>WebGUI::International::get('show page', 'Asset_ZipArchive'),
-value=>$self->getValue("showPage"),
-hoverHelp=>WebGUI::International::get('show page description', 'Asset_ZipArchive'),
);
return $tabform;
}
#-------------------------------------------------------------------
=head2 getIcon ( [small] )
Returns the icons to be associated with this asset
=head3 small
If this evaluates to True, then the smaller icon is returned.
=cut
sub getIcon {
my $self = shift;
my $small = shift;
return $session{config}{extrasURL}.'/assets/ziparchive.gif' unless ($small);
return $session{config}{extrasURL}.'/assets/small/ziparchive.gif';
}
#-------------------------------------------------------------------
=head2 processPropertiesFromFormPost ( )
Used to process properties from the form posted. In this asset, we use
this method to deflate the zip file into the proper folder
=cut
sub processPropertiesFromFormPost {
my $self = shift;
#File should be saved here by the superclass
$self->SUPER::processPropertiesFromFormPost;
my $storage = $self->getStorageLocation();
my $file = $self->get("filename");
#return unless $file;
unless($session{form}{showPage}) {
$storage->delete;
WebGUI::SQL->write("update FileAsset set filename=NULL where assetId=".quote($self->getId));
WebGUI::Session::setScratch("za_error",WebGUI::International::get("za_show_error","Asset_ZipArchive"));
return;
}
unless($file =~ m/\.tar/i || $file =~ m/\.zip/i) {
$storage->delete;
WebGUI::SQL->write("update FileAsset set filename=NULL where assetId=".quote($self->getId));
WebGUI::Session::setScratch("za_error",WebGUI::International::get("za_error","Asset_ZipArchive"));
return;
}
unless ($self->unzip($storage,$self->get("filename"))) {
WebGUI::ErrorHandler::warn(WebGUI::International::get("unzip_error","Asset_ZipArchive"));
}
}
#-------------------------------------------------------------------
=head2 purge ( )
This method is called when data is purged by the system.
=cut
sub purge {
my $self = shift;
return $self->SUPER::purge;
}
#-------------------------------------------------------------------
=head2 purgeRevision ( )
This method is called when data is purged by the system.
=cut
sub purgeRevision {
my $self = shift;
return $self->SUPER::purgeRevision;
}
#-------------------------------------------------------------------
=head2 view ( )
method called by the container www_view method. In this asset, this is
used to show the file to administrators.
=cut
sub view {
my $self = shift;
my %var = %{$self->get};
#WebGUI::ErrorHandler::warn($self->getId);
$var{controls} = $self->getToolbar;
if($session{scratch}{za_error}) {
$var{error} = $session{scratch}{za_error};
}
WebGUI::Session::deleteScratch("za_error");
my $storage = $self->getStorageLocation;
if($self->get("filename") ne "") {
$var{fileUrl} = $storage->getUrl($self->get("showPage"));
$var{fileIcon} = $storage->getFileIconUrl($self->get("showPage"));
}
unless($self->get("showPage")) {
$var{pageError} = "true";
}
return $self->processTemplate(\%var,$self->get("templateId"));
}
#-------------------------------------------------------------------
=head2 www_edit ( )
Web facing method which is the default edit page
=cut
sub www_edit {
my $self = shift;
return WebGUI::Privilege::insufficient() unless $self->canEdit;
$self->getAdminConsole->setHelp("zip archive add/edit", "Asset_ZipArchive");
return $self->getAdminConsole->render($self->getEditForm->print,
WebGUI::International::get('edit asset',"Asset_ZipArchive"));
}
#-------------------------------------------------------------------
=head2 www_view ( )
Web facing method which is the default view page. This method does a
302 redirect to the "showPage" file in the storage location.
=cut
sub www_view {
my $self = shift;
return WebGUI::Privilege::noAccess() unless $self->canView;
if (WebGUI::Session::isAdminOn()) {
return $self->getContainer->www_view;
}
WebGUI::HTTP::setRedirect($self->getFileUrl($self->getValue("showPage")));
return "";
}
1;

View file

@ -0,0 +1,504 @@
package WebGUI::Asset::Wobject::InOutBoard;
$VERSION = "0.5.3";
use strict;
use WebGUI::DateTime;
use WebGUI::FormProcessor;
use WebGUI::Grouping;
use WebGUI::HTMLForm;
use WebGUI::International;
use WebGUI::Paginator;
use WebGUI::Privilege;
use WebGUI::Session;
use WebGUI::SQL;
use WebGUI::URL;
use WebGUI::Asset::Wobject;
use WebGUI::ErrorHandler;
use Data::Dumper;
our @ISA = qw(WebGUI::Asset::Wobject);
#See line 285 if you wish to change the users visible in the delegate select list
#-------------------------------------------------------------------
sub _defineUsername {
my $data = shift;
if ($data->{firstName} ne "" && $data->{lastName} ne "") {
return join ' ', $data->{firstName}, $data->{lastName};
}
else {
return $data->{username};
}
}
#-------------------------------------------------------------------
sub _fetchNames {
my @userIds = @_;
my %nameHash;
my $sql = "select users.username,
users.userId,
a.fieldData as firstName,
b.fieldData as lastName
from users
left join userProfileData a on users.userId=a.userId and a.fieldName='firstName'
left join userProfileData b on users.userId=b.userId and b.fieldName='lastName'
where users.userId=?";
my $sth = WebGUI::SQL->prepare($sql);
foreach my $userId (@userIds) {
$sth->execute([ $userId ]);
$nameHash{ $userId } = _defineUsername($sth->hashRef);
}
$sth->finish;
return %nameHash;
}
#-------------------------------------------------------------------
sub _fetchDepartments {
return WebGUI::SQL->buildArray("select fieldData from userProfileData where fieldName='department' GROUP by fieldData");
}
#-------------------------------------------------------------------
sub definition {
my $class = shift;
my $definition = shift;
push(@{$definition}, {
tableName=>'InOutBoard',
className=>'WebGUI::Asset::Wobject::InOutBoard',
properties=>{
statusList => {
defaultValue => WebGUI::International::get(10, "Asset_InOutBoard")."\n"
.WebGUI::International::get(11, "Asset_InOutBoard")."\n",
fieldType=>"textarea"
},
reportViewerGroup => {
defaultValue => 3,
fieldType => "group"
},
inOutGroup => {
defaultValue => 2,
fieldType => "group"
},
inOutTemplateId => {
fieldType=>"template",
defaultValue => 'IOB0000000000000000001'
},
reportTemplateId => {
fieldType=>"template",
defaultValue => 'IOB0000000000000000002'
},
paginateAfter => {
fieldType=>"integer",
defaultValue => 50
},
}
});
return $class->SUPER::definition($definition);
}
#-------------------------------------------------------------------
sub getEditForm {
my $self = shift;
my $tabform = $self->SUPER::getEditForm();
$tabform->getTab("properties")->textarea(
-name=>"statusList",
-label=>WebGUI::International::get(1, "Asset_InOutBoard"),
-value=>$self->getValue("statusList"),
-subtext=>WebGUI::International::get(2, "Asset_InOutBoard"),
);
$tabform->getTab("display")->integer(
-name=>"paginateAfter",
-label=>WebGUI::International::get(12, "Asset_InOutBoard"),
-value=>$self->getValue("paginateAfter")
);
$tabform->getTab("display")->template (
-name => "inOutTemplateId",
-value => $self->getValue("inOutTemplateId"),
-label => WebGUI::International::get("In Out Template", "Asset_InOutBoard"),
-namespace => "InOutBoard"
);
$tabform->getTab("display")->template (
-name => "reportTemplateId",
-value => $self->getValue("reportTemplateId"),
-label => WebGUI::International::get(13, "Asset_InOutBoard"),
-namespace => "InOutBoard/Report"
);
$tabform->getTab("security")->group(
-name=>"reportViewerGroup",
-value=>[$self->getValue("reportViewerGroup")],
-label=>WebGUI::International::get(3, "Asset_InOutBoard")
);
$tabform->getTab("security")->group(
-name=>"inOutGroup",
-value=>[$self->getValue("inOutGroup")],
-label=>WebGUI::International::get('inOutGroup', "Asset_InOutBoard")
);
return $tabform;
}
#-------------------------------------------------------------------
sub getName {
return WebGUI::International::get(9,"Asset_InOutBoard");
}
#-------------------------------------------------------------------
sub view {
my $self = shift;
my %var;
my $url = $self->getUrl('func=view');
if (WebGUI::Grouping::isInGroup($self->getValue("reportViewerGroup"))) {
$var{'viewReportURL'} = $self->getUrl("func=viewReport");
$var{canViewReport} = 1;
}
else { $var{canViewReport} = 0; }
my $statusUserId = $session{scratch}{userId} || $session{user}{userId};
my $statusListString = $self->getValue("statusList");
chop($statusListString);
my @statusListArray = split("\n",$statusListString);
my $statusListHashRef;
foreach my $status (@statusListArray) {
chop($status);
$statusListHashRef->{$status} = $status;
}
#WebGUI::ErrorHandler::warn("VIEW: userId: ".$statusUserId."\n" );
my ($status) = WebGUI::SQL->quickArray("select status from InOutBoard_status where userId=".quote($statusUserId)." and assetId=".quote($self->getId));
##Find all the users for which I am a delegate
my @users = WebGUI::SQL->buildArray("select userId from InOutBoard_delegates where assetId=".quote($self->getId)." and delegateUserId=".quote($session{user}{userId}));
my $f = WebGUI::HTMLForm->new(-action=>$self->getUrl);
if (@users) {
my %nameHash;
tie %nameHash, "Tie::IxHash";
%nameHash = _fetchNames(@users);
$nameHash{""} = WebGUI::International::get('myself',"Asset_InOutBoard");
%nameHash = WebGUI::Utility::sortHash(%nameHash);
$f->selectList(
-name=>"delegate",
-options=>\%nameHash,
-value=>[ $session{scratch}{userId} ],
-label=>WebGUI::International::get('delegate', "Asset_InOutBoard"),
-extras=>q|onchange="this.form.submit();"|,
);
}
$f->radioList(
-name=>"status",
-value=>$status,
-options=>$statusListHashRef,
-label=>WebGUI::International::get(5, "Asset_InOutBoard")
);
$f->text(
-name=>"message",
-label=>WebGUI::International::get(6, "Asset_InOutBoard")
);
$f->hidden(
-name=>"func",
-value=>"setStatus"
);
$f->submit;
my ($isInGroup) = WebGUI::SQL->quickArray("select count(*) from groupings where userId=".quote($session{user}{userId})." and groupId=".quote($self->get("inOutGroup")));
if ($isInGroup) {
$var{displayForm} = 1;
$var{'form'} = $f->print;
$var{'selectDelegatesURL'} = $self->getUrl("func=selectDelegates");
}
else { $var{displayForm} = 0; }
my $lastDepartment = "_nothing_";
my $p = WebGUI::Paginator->new($url, $self->getValue("paginateAfter"));
my $sql = "select users.username,
users.userId,
a.fieldData as firstName,
InOutBoard_status.message,
b.fieldData as lastName,
InOutBoard_status.status,
InOutBoard_status.dateStamp,
c.fieldData as department,
groupings.groupId
from users, InOutBoard, groupings
left join userProfileData a on users.userId=a.userId and a.fieldName='firstName'
left join userProfileData b on users.userId=b.userId and b.fieldName='lastName'
left join userProfileData c on users.userId=c.userId and c.fieldName='department'
left join InOutBoard_status on users.userId=InOutBoard_status.userId and InOutBoard_status.assetId=".quote($self->getId())."
where users.userId<>'1' and groupings.groupId=InOutBoard.inOutGroup and groupings.userId=users.userId and InOutBoard.inOutGroup=".quote($self->get("inOutGroup"))."
group by userId
order by department, lastName, firstName";
$p->setDataByQuery($sql);
my $rowdata = $p->getPageData();
my @rows;
foreach my $data (@$rowdata) {
my %row;
if ($lastDepartment ne $data->{department}) {
$row{deptHasChanged} = 1;
$row{'department'} = ($data->{department}||WebGUI::International::get(7, "Asset_InOutBoard"));
$lastDepartment = $data->{department};
}
else { $row{deptHasChanged} = 0; }
if ($data->{firstName} ne "" && $data->{lastName} ne "") {
$row{'username'} = $data->{firstName}." ".$data->{lastName};
}
else {
$row{'username'} = $data->{username};
}
$row{'status'} = ($data->{status}||WebGUI::International::get(15, "Asset_InOutBoard"));
$row{'dateStamp'} = WebGUI::DateTime::epochToHuman($data->{dateStamp});
$row{'message'} = ($data->{message}||"&nbsp;");
push (@rows, \%row);
}
$var{rows_loop} = \@rows;
$var{'paginateBar'} = $p->getBarTraditional();
$p->appendTemplateVars(\%var);
return $self->processTemplate(\%var,$self->getValue("inOutTemplateId"));
}
#-------------------------------------------------------------------
sub www_edit {
my $self = shift;
return WebGUI::Privilege::insufficient() unless $self->canEdit;
return $self->getAdminConsole->render($self->getEditForm->print,WebGUI::International::get("Edit In/Out Board","Asset_InOutBoard"));
}
#-------------------------------------------------------------------
sub www_selectDelegates {
my $self = shift;
#Uncomment the sql query below (lines 286 - 294) to show all users of the system in the delegate select list
#my $sql = sprintf "select users.username,
#users.userId,
#a.fieldData as firstName,
#b.fieldData as lastName
#from users
#left join userProfileData a on users.userId=a.userId and a.fieldName='firstName'
#left join userProfileData b on users.userId=b.userId and b.fieldName='lastName'
#where users.userId<>'1' and users.status='Active' and users.userId<>%s
#group by userId", quote($session{user}{userId});
#Comment the sql query below (lines 297 - 307) to show all users of the system in the delegate select list
my $sql = sprintf "select users.username,
users.userId,
a.fieldData as firstName,
b.fieldData as lastName
from users, InOutBoard, groupings
left join userProfileData a on users.userId=a.userId and a.fieldName='firstName'
left join userProfileData b on users.userId=b.userId and b.fieldName='lastName'
left join userProfileData c on users.userId=c.userId and c.fieldName='department'
left join InOutBoard_status on users.userId=InOutBoard_status.userId and InOutBoard_status.assetId=%s
where users.userId<>'1' and groupings.groupId=InOutBoard.inOutGroup and users.status='Active' and users.userId <> %s and groupings.userId=users.userId and InOutBoard.inOutGroup=%s
group by userId", quote($self->getId), quote($session{user}{userId}), quote($self->getValue("inOutGroup")) ;
my %userNames = ();
my $sth = WebGUI::SQL->read($sql);
while (my $data = $sth->hashRef) {
$userNames{ $data->{userId} } = _defineUsername($data);
}
$sth->finish;
$sql = sprintf "select delegateUserId from InOutBoard_delegates where userId=%s and assetId=%s",
quote($session{user}{userId}), quote($self->getId);
my $delegates = WebGUI::SQL->buildArrayRef($sql);
my $f = WebGUI::HTMLForm->new(-action=>$self->getUrl);
$f->hidden(
-name => "func",
-value => "selectDelegatesEditSave"
);
$f->selectList(
-name => "delegates",
-label => WebGUI::International::get('in/out status delegates','Asset_InOutBoard'),
-options => \%userNames,
-multiple => 1, ##Multiple select
-size => 10, ##Multiple select
-sortByValue => 1,
-value => $delegates, ##My current delegates, if any
-subtext => WebGUI::International::get('in/out status delegates subtext','Asset_InOutBoard'),
);
$f->submit;
my $ac = $self->getAdminConsole;
return $ac->render($f->print,
WebGUI::International::get('select delegate','Asset_InOutBoard'));
}
#-------------------------------------------------------------------
sub www_selectDelegatesEditSave {
my $self = shift;
my @delegates = WebGUI::FormProcessor::selectList("delegates");
WebGUI::SQL->write("delete from InOutBoard_delegates where assetId=".quote($self->getId)." and userId=".quote($session{user}{userId}));
foreach my $delegate (@delegates) {
WebGUI::SQL->write("insert into InOutBoard_delegates
(userId,delegateUserId,assetId) values
(".quote($session{user}{userId}).",".quote($delegate).",".quote($self->getId).")");
}
return "";
}
#-------------------------------------------------------------------
sub www_setStatus {
my $self = shift;
#WebGUI::ErrorHandler::warn("delegateId: ". $session{form}{delegate}."\n" );
#WebGUI::ErrorHandler::warn("userId: ".$session{scratch}{userId} ."\n" );
if ($session{form}{delegate} eq $session{scratch}{userId}) {
#WebGUI::ErrorHandler::warn("Wrote data and removed scratch\n");
my $sessionUserId = $session{scratch}{userId} || $session{user}{userId};
#WebGUI::ErrorHandler::warn("user Id: ".$sessionUserId."\n");
WebGUI::Session::deleteScratch("userId");
WebGUI::SQL->write("delete from InOutBoard_status where userId=".quote($sessionUserId)." and assetId=".quote($self->getId));
WebGUI::SQL->write("insert into InOutBoard_status (assetId,userId,status,dateStamp,message) values (".quote($self->getId).",".quote($sessionUserId).","
.quote($session{form}{status}).",".WebGUI::DateTime::time().",".quote($session{form}{message}).")");
WebGUI::SQL->write("insert into InOutBoard_statusLog (assetId,userId,createdBy,status,dateStamp,message) values (".quote($self->getId).",".quote($sessionUserId).",".quote($session{user}{userId}).","
.quote($session{form}{status}).",".WebGUI::DateTime::time().",".quote($session{form}{message}).")");
}
else {
#WebGUI::ErrorHandler::warn("Set scratch, redisplay\n");
#WebGUI::ErrorHandler::warn(sprintf "Delegate is %s\n", $session{form}{delegate});
WebGUI::Session::setScratch("userId",$session{form}{delegate});
}
return $self->www_view;
}
sub www_view {
my $self = shift;
$self->SUPER::www_view(1);
}
#-------------------------------------------------------------------
sub www_viewReport {
my $self = shift;
return "" unless (WebGUI::Grouping::isInGroup($self->getValue("reportViewerGroup")));
my %var;
my $f = WebGUI::HTMLForm->new(-action=>$self->getUrl, -method=>"GET");
my %changedBy = ();
$f->hidden(
-name=>"func",
-value=>"viewReport"
);
$f->hidden(
-name=>"doit",
-value=>"1"
);
my $startDate = WebGUI::DateTime::addToDate(WebGUI::DateTime::time(),0,0,-15);
$startDate = WebGUI::FormProcessor::date("startDate") if ($session{form}{doit});
$f->date(
-name=>"startDate",
-label=>WebGUI::International::get(16, "Asset_InOutBoard"),
-value=>$startDate
);
my $endDate = WebGUI::FormProcessor::date("endDate");
$f->date(
-name=>"endDate",
-label=>WebGUI::International::get(17, "Asset_InOutBoard"),
-value=>$endDate
);
my %depHash;
%depHash = map { $_ => $_ } (_fetchDepartments(),
WebGUI::International::get('all departments', 'Asset_InOutBoard'));
my $defaultDepartment = $session{form}{selectDepartment}
|| WebGUI::International::get('all departments', 'Asset_InOutBoard');
my $departmentSQLclause = ($defaultDepartment eq WebGUI::International::get('all departments', 'Asset_InOutBoard'))
? ''
: 'and c.fieldData='.quote($defaultDepartment);
$f->selectList(
-name=>"selectDepartment",
-options=>\%depHash,
-value=>[ $defaultDepartment ],
-label=>WebGUI::International::get('filter departments', "Asset_InOutBoard"),
);
my %paginHash;
tie %paginHash, "Tie::IxHash"; ##Because default sort order is alpha
%paginHash = (50 => 50, 100 => 100, 300 => 300, 500 => 500, 1000 => 1000, 10_000 => 10_000,);
my $pageReportAfter = $session{form}{reportPagination} || 50;
$f->selectList(
-name=>"reportPagination",
-options=>\%paginHash,
-value=>[ $pageReportAfter ],
-label=>WebGUI::International::get(14, "Asset_InOutBoard"),
);
$f->submit(-value=>"Search");
$var{'form'} = $f->print;
my $url = $self->getUrl("func=viewReport&selectDepartment=$session{form}{selectDepartment}&reportPagination=$session{form}{reportPagination}&startDate=$session{form}{startDate}&endDate=$session{form}{endDate}&doit=1");
if ($session{form}{doit}) {
$var{showReport} = 1;
$endDate = WebGUI::DateTime::addToTime($endDate,24,0,0);
my $lastDepartment = "_none_";
my $p = WebGUI::Paginator->new($url, $pageReportAfter);
my $sql = "select users.username,
users.userId,
a.fieldData as firstName,
InOutBoard_statusLog.message,
b.fieldData as lastName,
InOutBoard_statusLog.status,
InOutBoard_statusLog.dateStamp,
InOutBoard_statusLog.createdBy,
c.fieldData as department,
groupings.groupId
from users, InOutBoard, groupings
left join userProfileData a on users.userId=a.userId and a.fieldName='firstName'
left join userProfileData b on users.userId=b.userId and b.fieldName='lastName'
left join userProfileData c on users.userId=c.userId and c.fieldName='department'
left join InOutBoard_statusLog on users.userId=InOutBoard_statusLog.userId and InOutBoard_statusLog.assetId=".quote($self->getId())."
where users.userId<>'1' and
groupings.groupId=".quote($self->getValue("inOutGroup"))." and
groupings.userId=users.userId and
InOutBoard_statusLog.dateStamp>=$startDate and
InOutBoard_statusLog.dateStamp<=$endDate
$departmentSQLclause
group by InOutBoard_statusLog.dateStamp
order by department, lastName, firstName, InOutBoard_statusLog.dateStamp";
#WebGUI::ErrorHandler::warn("QUERY: $sql\n");
$p->setDataByQuery($sql);
my $rowdata = $p->getPageData();
my @rows;
foreach my $data (@$rowdata) {
my %row;
if ($lastDepartment ne $data->{department}) {
$row{deptHasChanged} = 1;
$row{'department'} = ($data->{department}||WebGUI::International::get(7, "Asset_InOutBoard"));
$lastDepartment = $data->{department};
}
else { $row{deptHasChanged} = 0; }
$row{'username'} = _defineUsername($data);
$row{'status'} = ($data->{status}||WebGUI::International::get(15, "Asset_InOutBoard"));
$row{'dateStamp'} = WebGUI::DateTime::epochToHuman($data->{dateStamp});
$row{'message'} = ($data->{message}||"&nbsp;");
if (! exists $changedBy{ $data->{createdBy} }) {
my %whoChanged = _fetchNames($data->{createdBy});
$changedBy{ $data->{createdBy} } = $whoChanged{ $data->{createdBy} };
}
$row{'createdBy'} = $changedBy{ $data->{createdBy} };
push (@rows, \%row);
}
$var{rows_loop} = \@rows;
$var{'paginateBar'} = $p->getBarTraditional();
$var{'username.label'} = WebGUI::International::get('username.label','Asset_InOutBoard');
$var{'status.label'} = WebGUI::International::get(5,'Asset_InOutBoard');
$var{'date.label'} = WebGUI::International::get('date.label','Asset_InOutBoard');
$var{'message.label'} = WebGUI::International::get('message.label','Asset_InOutBoard');
$var{'updatedBy.label'} = WebGUI::International::get('updatedBy.label','Asset_InOutBoard');
$p->appendTemplateVars(\%var);
}
else { $var{showReport} = 0; }
return $self->processStyle($self->processTemplate(\%var, $self->getValue("reportTemplateId")));
}
1;