diff --git a/lib/WebGUI/Asset/EMSSubmission.pm b/lib/WebGUI/Asset/EMSSubmission.pm
index 7d457bd76..22453d6d8 100644
--- a/lib/WebGUI/Asset/EMSSubmission.pm
+++ b/lib/WebGUI/Asset/EMSSubmission.pm
@@ -360,13 +360,9 @@ dav::log 'EMSSubmission::www_editSubmission: got self param';
my $params = shift || { };
my $session = $parent->session;
my $i18n = WebGUI::International->new($parent->session,'Asset_EventManagementSystem');
- my $assetId = $self ? $self->getId : $params->{assetId} || $session->form->get('assetId');
+ my $assetId = $self ? $self->getId : $params->{assetId} || $session->form->get('assetId') || 'new';
- if( ! defined( $assetId ) ) {
- # if somebody calls without an assetId then display the queue for the EMS (grandparent)
-dav::log 'EMSSubmission::www_editSubmission: asseId not defined';
- return $parent->getParent->www_viewSubmissionQueue;
- } elsif( $assetId ne 'new' ) {
+ if( $assetId ne 'new' ) {
dav::log 'EMSSubmission::www_editSubmission: asseId ne new';
$self ||= WebGUI::Asset->newByDynamicClass($session,$assetId);
if (!defined $self) {
diff --git a/lib/WebGUI/Asset/EMSSubmissionForm.pm b/lib/WebGUI/Asset/EMSSubmissionForm.pm
index 6f3cee7a0..a9738ad9a 100644
--- a/lib/WebGUI/Asset/EMSSubmissionForm.pm
+++ b/lib/WebGUI/Asset/EMSSubmissionForm.pm
@@ -259,8 +259,16 @@ sub www_editSubmissionForm {
WebGUI::HTML::filter($_->get('description'),'all')
)
} ( @$res ) );
- return $parent->processStyle( '
' . $i18n->get('select form to edit') .
+ my $title = $i18n->get('select form to edit') ;
+ my $content = $parent->processStyle( '' . $title .
'
' );
+ if( $session->form->get('asJson') ) {
+ $session->http->setMimeType( 'application/json' );
+ return JSON->new->encode( { text => $content, title => $title } );
+ } else {
+ $session->http->setMimeType( 'text/html' );
+ return $content;
+ }
}
} elsif( $assetId ne 'new' ) {
$self ||= WebGUI::Asset->newByDynamicClass($session,$assetId);
diff --git a/lib/WebGUI/Asset/Wobject/EventManagementSystem.pm b/lib/WebGUI/Asset/Wobject/EventManagementSystem.pm
index 41d92c347..4dbde6912 100644
--- a/lib/WebGUI/Asset/Wobject/EventManagementSystem.pm
+++ b/lib/WebGUI/Asset/Wobject/EventManagementSystem.pm
@@ -50,7 +50,7 @@ sub addGroupToSubmitList {
my @ids = split(' ', $self->get('eventSubmissionGroups'));
my %h;
@ids = map { $h{$_}++ == 0 ? $_ : () } ( $groupId, @ids );
- $self->update({eventSubmissionGroups => join( ' ', @ids ) });
+ $self->addRevision({eventSubmissionGroups => join( ' ', @ids ) });
}
#-------------------------------------------------------------------
@@ -107,6 +107,7 @@ returns true is the current user can submit to any form attached to this EMS
sub canSubmit {
my $self = shift;
my $user = $self->session->user;
+ return 0 if ! $self->hasSubmissionForms;
for my $groupId (split ' ', $self->get('eventSubmissionGroups')) {
return 1 if $user->isInGroup($groupId);
}
@@ -433,7 +434,7 @@ sub getNextSubmissionId {
my $self = shift;
#my $submissionId = $self->get('nextSubmissionId');
my ($submissionId) = $self->session->db->read('select nextSubmissionId from EventManagementSystem where assetId = ?', [ $self->getId ] )->array;
- $self->update( { nextSubmissionId => ($submissionId + 1) } );
+ $self->addRevision( { nextSubmissionId => ($submissionId + 1) } );
return $submissionId;
}
diff --git a/lib/WebGUI/Workflow/Activity/CleanupEMSSubmissions.pm b/lib/WebGUI/Workflow/Activity/CleanupEMSSubmissions.pm
index 4d72f04d1..df8c8a85a 100644
--- a/lib/WebGUI/Workflow/Activity/CleanupEMSSubmissions.pm
+++ b/lib/WebGUI/Workflow/Activity/CleanupEMSSubmissions.pm
@@ -72,29 +72,35 @@ sub execute {
my $self = shift;
my $session = $self->session;
my $root = WebGUI::Asset->getRoot($session);
-return $self->ERROR;
+
+ # keep track of how much time it's taking
+ my $start = time;
+ my $limit = 2_500;
+ my $timeLimit = 120;
+
+ my $list = $root->getLineage( ['children'], { returnObjects => 1,
+ includeOnlyClasses => ['WebGUI::Asset::EMSSubmissionForm'],
+ } );
- my $sth = $session->db->read("select assetId from asset where className='WebGUI::Asset::Wobject::HelpDesk'");
- while (my ($assetId) = $sth->array) {
- my $hd = WebGUI::Asset->new($session,$assetId,"WebGUI::Asset::Wobject::HelpDesk");
- next unless defined $hd;
-
- my $closeAfter = $hd->get("closeTicketsAfter");
-
- my $rules = {};
- $rules->{'joinClass' } = "WebGUI::Asset::Ticket";
- $rules->{'whereClause' } = qq{Ticket.ticketStatus = 'resolved' and (Ticket.resolvedDate + $closeAfter <= UNIX_TIMESTAMP(NOW()))};
- $rules->{'includeOnlyClasses'} = ['WebGUI::Asset::Ticket'];
- $rules->{'returnObjects' } = 1;
-
- my $tickets = $hd->getLineage(['children'], $rules);
- foreach my $ticket (@{$tickets}) {
- $ticket->setStatus("closed");
- }
+ for my $emsf ( @$list ) {
+ my whereClause = q{ ( submissionStatus='denied' }
+ if( $emsf->get('deleteCreatedItems') ) {
+ $whereClause .= q{ or submissionStatus='created'};
+ }
+ my $checkDate = time - ( 60*60*24* $emsf->get('daysBeforeCleanup') );
+ $whereClause .= q{ ) and lastModifiedDate < } . $checkDate;
+ my $res = $emsf->getLineage(['children'],{
+ includeOnlyClasses => ['WebGUI::Asset::EMSSubmission'],
+ whereClause => $whereClause,
+ } );
+ for my $submission ( @$res ) {
+ $submission->purge;
+ $limit--;
+ return $self->WAITING(1) if ! $limit or time > $start + $timeLimit;
+ }
}
- return $self->COMPLETE;
+ return $self->COMPLETE;
}
1;
-
diff --git a/lib/WebGUI/Workflow/Activity/ProcessEMSApprovals.pm b/lib/WebGUI/Workflow/Activity/ProcessEMSApprovals.pm
index 092ee4f11..5a73b4bda 100644
--- a/lib/WebGUI/Workflow/Activity/ProcessEMSApprovals.pm
+++ b/lib/WebGUI/Workflow/Activity/ProcessEMSApprovals.pm
@@ -68,6 +68,44 @@ See WebGUI::Workflow::Activity::execute() for details.
=cut
+sub execute {
+ my $self = shift;
+ my $session = $self->session;
+ my $root = WebGUI::Asset->getRoot($session);
+
+ # keep track of how much time it's taking
+ my $start = time;
+ my $limit = 2_500;
+ my $timeLimit = 120;
+
+ my $list = $root->getLineage( ['children'], { returnObjects => 1,
+ includeOnlyClasses => ['WebGUI::Asset::EMSSubmissionForm'],
+ } );
+
+ for my $emsf ( @$list ) {
+ my whereClause = q{ ( submissionStatus='approved' }
+ my $res = $emsf->getLineage(['children'],{
+ includeOnlyClasses => ['WebGUI::Asset::EMSSubmission'],
+ whereClause => $whereClause,
+ } );
+ for my $submission ( @$res ) {
+ my %properties = $submission->get;
+ delete $properties{submissionId};
+ delete $properties{submissionStatus};
+ delete $properties{sendEmailOnChange};
+ delete $properties{ticketId};
+ my $ticketId = $emsf->ems->addChild(
+ className => 'WebGUI::Asset::Sku::EMSTicket',
+ %properties;
+ );
+ $submission->update({ ticketId => $ticketId });
+ $limit--;
+ return $self->WAITING(1) if ! $limit or time > $start + $timeLimit;
+ }
+ }
+ return $self->COMPLETE;
+}
+
sub execute {
my $self = shift;
my $session = $self->session;
diff --git a/t/Asset/EMSSubmissionForm.t b/t/Asset/EMSSubmissionForm.t
index bce9e1bc3..10a0438fb 100644
--- a/t/Asset/EMSSubmissionForm.t
+++ b/t/Asset/EMSSubmissionForm.t
@@ -341,7 +341,7 @@ is($sub1->get('status'),'approved','set status to approved');
$sub2->update({ status => 'denied' });
is($sub2->get('status'),'denied','set status to denied');
-SKIP: { skip "workflow activities not coded yet", 10 unless 0;
+SKIP: { skip "workflow activities not coded yet", 10 if 0;
# create the workflows/activities for processing
my $approveSubmissions = WebGUI::Test::Activity->create( $session,
diff --git a/www/extras/wobject/EMS/submission.js b/www/extras/wobject/EMS/submission.js
index ac16f820e..9aebca2fe 100644
--- a/www/extras/wobject/EMS/submission.js
+++ b/www/extras/wobject/EMS/submission.js
@@ -154,26 +154,26 @@ WebGUI.EMS = function (configs) {
}
alert(message);
return;
- } else if( typeof(WebGUI.EMS.Items[response.submissionId]) == "undefined"
- || WebGUI.EMS.Items[response.submissionId] == null ) {
+ } else if( typeof(WebGUI.EMS.Items[response.title]) == "undefined"
+ || WebGUI.EMS.Items[response.title] == null ) {
// if there is a tab .. close it,
// at least until I can get the JS/HTML re-written to handle multiple tabs
// there should only be one
- for( var ticketId in WebGUI.EMS.Tickets ) { WebGUI.EMS.closeTab(ticketId) }
+ for( var item in WebGUI.EMS.Items ) { WebGUI.EMS.closeTab(item) }
var myContent = document.createElement("div");
- myContent.innerHTML = response.itemText;
+ myContent.innerHTML = response.text;
myTab = new YAHOO.widget.Tab({
- label: response.submissionId + '
',
contentEl: myContent
});
WebGUI.EMS.Tabs.addTab( myTab );
YAHOO.util.Event.on(myTab.getElementsByClassName('close')[0], 'click', WebGUI.EMS.closeTab , myTab);
- WebGUI.EMS.Items[response.submissionId] = new Object();
- WebGUI.EMS.Items[response.submissionId].Tab = myTab;
+ WebGUI.EMS.Items[response.title] = new Object();
+ WebGUI.EMS.Items[response.title].Tab = myTab;
} else {
- myTab = WebGUI.EMS.Tickets[response.submissionId].Tab;
- myTab.set('content', response.itemText);
+ myTab = WebGUI.EMS.Tickets[response.title].Tab;
+ myTab.set('content', response.text);
}
// make sure the script on the ticket has run
// if( typeof( WebGUI.ticketJScriptRun ) == "undefined" ) {