diff --git a/lib/WebGUI/Asset/Wobject/EventManagementSystem.pm b/lib/WebGUI/Asset/Wobject/EventManagementSystem.pm index a1ce4fbdd..0905db0e5 100644 --- a/lib/WebGUI/Asset/Wobject/EventManagementSystem.pm +++ b/lib/WebGUI/Asset/Wobject/EventManagementSystem.pm @@ -1260,7 +1260,7 @@ sub www_exportEvents { # set http header $session->response->header( 'Content-Disposition' => qq{attachment; filename="}.$self->getTitle().'.csv"' ); $session->response->content_type('application/excel'); - + # add file header my @header = (); foreach my $field (@{$fields}) { @@ -1293,7 +1293,7 @@ sub www_exportEvents { last; } } - + # finished return "chunked"; } @@ -1333,13 +1333,13 @@ sub www_getAllSubmissions { $rules->{'orderByClause' } = $session->db->quote_identifier( $orderByColumn ) . ' ' . $orderByDirection if $orderByColumn; my $sql = ""; - + $sql = $self->getLineageSql(['descendants'], $rules); my $startIndex = $form->get( 'startIndex' ) || 1; my $rowsPerPage = $form->get( 'rowsPerPage' ) || 25; my $currentPage = int ( $startIndex / $rowsPerPage ) + 1; - + my $p = WebGUI::Paginator->new( $session, '', $rowsPerPage, 'pn', $currentPage ); $p->setDataByQuery($sql); @@ -1349,10 +1349,10 @@ sub www_getAllSubmissions { $tableInfo->{'sort' } = $orderByColumn; $tableInfo->{'dir' } = $orderByDirection; $tableInfo->{'records' } = []; - + for my $record ( @{ $p->getPageData } ) { my $asset = WebGUI::Asset->newById( $session, $record->{assetId} ); - + my $lastReplyBy = $asset->get("lastReplyBy"); if ($lastReplyBy) { $lastReplyBy = WebGUI::User->new($session,$lastReplyBy)->username; @@ -1377,7 +1377,7 @@ sub www_getAllSubmissions { push @{ $tableInfo->{ records } }, \%fields; } - + $session->response->content_type( 'application/json' ); return JSON->new->encode( $tableInfo ); } @@ -1476,7 +1476,7 @@ sub www_getRegistrantAsJson { $badgeInfo->{sku} = $badge->sku; $badgeInfo->{assetId} = $badge->getId; $badgeInfo->{hasPurchased} = ($badgeInfo->{purchaseComplete}) ? 1 : 0; - + # get existing tickets my $existingTickets = $db->read("select ticketAssetId from EMSRegistrantTicket where badgeId=? and purchaseComplete=1",[$badgeId]); while (my ($id) = $existingTickets->array) { @@ -1554,7 +1554,7 @@ sub www_getRegistrantAsJson { price => $sku->getPrice+0 * $item->get('quantity'), }); } - + # it's a ribbon elsif ($sku->isa('WebGUI::Asset::Sku::EMSRibbon')) { push(@ribbons, { @@ -1576,7 +1576,7 @@ sub www_getRegistrantAsJson { $badgeInfo->{tokens} = \@tokens; $badgeInfo->{tickets} = \@tickets; $badgeInfo->{ribbons} = \@ribbons; - + # build json datasource return JSON->new->encode($badgeInfo); } @@ -1597,10 +1597,10 @@ sub www_getRegistrantsAsJson { my $startIndex = $form->get('startIndex') || 0; my $numberOfResults = $form->get('results') || 25; my $keywords = $form->get('keywords'); - + my $sql = "select SQL_CALC_FOUND_ROWS * from EMSRegistrant where purchaseComplete=1 and emsAssetId=?"; my @params = ($self->getId); - + # user or staff unless ($self->isRegistrationStaff) { $sql .= " and userId=?"; @@ -1639,7 +1639,7 @@ sub www_getRegistrantsAsJson { $results{'startIndex'} = $startIndex; $results{'sort'} = undef; $results{'dir'} = "asc"; - + # build json datasource $session->response->content_type('application/json'); return JSON->new->encode(\%results); @@ -1813,14 +1813,14 @@ sub www_getTicketsAsJson { my %results = (); my @ids = (); my $keywords = $form->get('keywords'); - + # looking for specific events if ($keywords =~ m{^[\d+,*\s*]+$}) { @ids = $db->buildArray("select distinct(EMSTicket.assetId) from EMSTicket left join asset using (assetId) where asset.parentId=? and EMSTicket.eventNumber in (".$keywords.") and asset.state='published' order by EMSTicket.eventNumber",[$self->getId]); } - + # looking for keywords elsif ($keywords ne "") { @ids = @{WebGUI::Search->new($session)->search({ @@ -1829,22 +1829,22 @@ sub www_getTicketsAsJson { classes => ['WebGUI::Asset::Sku::EMSTicket'], })->getAssetIds}; } - + # just get all tickets else { @ids = $db->buildArray("select assetId from asset left join EMSTicket using (assetId) where parentId=? and className='WebGUI::Asset::Sku::EMSTicket' and state='published' and revisionDate=(select max(revisionDate) from EMSTicket where assetId=asset.assetId) order by $sortKey $sortDir", [$self->getId]); } - + # get badge's badge groups my $badgeId = $form->get('badgeId'); my @badgeGroups = (); if (defined $badgeId) { my $assetId = $db->quickScalar("select badgeAssetId from EMSRegistrant where badgeId=?",[$badgeId]); - my $badge = WebGUI::Asset->newById($session, $assetId); + my $badge = eval { WebGUI::Asset->newById($session, $assetId); }; @badgeGroups = split("\n",$badge->relatedBadgeGroups) if (defined $badge); } - + # get a list of tickets already associated with the badge my @existingTickets = $db->buildArray("select ticketAssetId from EMSRegistrantTicket where badgeId=?",[$badgeId]); @@ -1852,7 +1852,7 @@ className='WebGUI::Asset::Sku::EMSTicket' and state='published' and revisionDate my $counter = 0; my $totalTickets = scalar(@ids); my @records = (); - foreach my $id (@ids) { + TICKETID: foreach my $id (@ids) { # skip tickets we already have if ($id ~~ @existingTickets) { @@ -1860,21 +1860,15 @@ className='WebGUI::Asset::Sku::EMSTicket' and state='published' and revisionDate next; } - my $ticket = WebGUI::Asset->newById($session, $id); - - # skip borked tickets - unless (defined $ticket) { - $session->log->warn("EMSTicket $id couldn't be instanciated by EMS ".$self->getId."."); + my $ticket = eval { WebGUI::Asset->newById($session, $id); }; + if (my $e = Exception::Class->caught()) { + $session->log->warn("EMSTicket $id couldn't be instanciated by EMS ".$self->getId.'. '.$e->full_message. "."); $totalTickets--; - next; - } - - # skip tickets we can't view - unless ($ticket->canView) { - $totalTickets--; - next; - } - + next TICKETID; + } + + next TICKETID if !$ticket; + # skip tickets not in our badge's badge groups if ($badgeId ne "" && scalar(@badgeGroups) > 0 && $ticket->relatedBadgeGroups ne '') { # skip check if it has no badge groups my @groups = split("\n",$ticket->relatedBadgeGroups); @@ -1898,7 +1892,7 @@ className='WebGUI::Asset::Sku::EMSTicket' and state='published' and revisionDate # gotta get to the page we're working with $counter++; next unless ($counter >= $startIndex+1); - + # publish the data for this ticket my $description = $ticket->description; my $data = $ticket->eventMetaData; @@ -1929,7 +1923,7 @@ className='WebGUI::Asset::Sku::EMSTicket' and state='published' and revisionDate }); last unless (scalar(@records) < $numberOfResults); } - + # humor my $find = pack('u',$keywords); chomp $find; @@ -1937,7 +1931,7 @@ className='WebGUI::Asset::Sku::EMSTicket' and state='published' and revisionDate push(@records, {title=>unpack('u',q|022=M('-Osession->privilege->insufficient unless $self->canEdit; my $i18n = WebGUI::International->new($self->session,'Asset_EventManagementSystem'); my $form = $self->session->form; - + # header, with optional errors as unordered list my $page_header = $i18n->get('import form header'); if (@$errors_aref) { @@ -2075,7 +2069,7 @@ $|=1; my $form = $session->form; my $ignoreFirst = $form->get("ignore_first_line"); my $validate = WebGUI::FormValidator->new($session); - + # find fields to import $out->print("Finding fields to import...\n",1); my @import = $form->get("fieldsToImport"); @@ -2089,12 +2083,12 @@ $|=1; } $i++; } - + # get csv data $out->print("Reading file...\n",1); my $storage = WebGUI::Storage->createTemp($session); my $filename = $storage->addFileFromFormPost("file_file"); - + # do import my $first = 1; if (open my $file, "<", $storage->getPath($filename)) { @@ -2168,7 +2162,7 @@ $|=1; else { $out->print($i18n->get("no import took place")."\n",1); } - + # clean up $out->print("The import took ".Time::HiRes::tv_interval($start)." seconds to run.\n",1); $storage->delete; @@ -2278,10 +2272,10 @@ Displays an admin interface for managing a registrant. sub www_manageRegistrant { my $self = shift; my $session = $self->session; - + # check privs return $session->privilege->insufficient unless ($self->isRegistrationStaff); - + # setup my $badgeId = $self->session->form->get('badgeId'); my $db = $session->db; @@ -2292,7 +2286,7 @@ sub www_manageRegistrant { unless ($registrant->{badgeId} ne "") { return $self->www_lookupRegistrant; } - + # build form my $f = WebGUI::FormBuilder->new($session, action=>$self->getUrl, extras=>'class="manageRegistrant"'); $f->addField( "submit", name => "send" ); @@ -2366,7 +2360,7 @@ sub www_manageRegistrant { defaultValue => $registrant->{notes} ); $f->addField( "submit", name => "send" ); - + # build html my $output = q|
@@ -2382,7 +2376,7 @@ sub www_manageRegistrant {
|; - + if ($registrant->{hasCheckedIn}) { $output .= q||.$i18n->get('checked in').q||; } @@ -2405,7 +2399,7 @@ sub www_manageRegistrant { $output .= q| • |.$i18n->get('add more items').q|


|; - + # ticket management my $existingTickets = $db->read("select ticketAssetId, transactionItemId from EMSRegistrantTicket where badgeId=? and purchaseComplete=1",[$badgeId]); while (my ($id, $itemId) = $existingTickets->array) {