Skip to content

Commit e01245b

Browse files
chore: Revert to main version due to conflicts with rebase
1 parent c0b7412 commit e01245b

File tree

2 files changed

+187
-191
lines changed

2 files changed

+187
-191
lines changed

app/Http/Controllers/Apis/Protected/Summit/OAuth2SummitTicketApiController.php

Lines changed: 187 additions & 186 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
use models\oauth2\IResourceServerContext;
2929
use models\summit\IOrderConstants;
3030
use models\summit\ISummitAttendeeRepository;
31-
use models\summit\ISummitAttendeeRepository;
3231
use models\summit\ISummitAttendeeTicketRepository;
3332
use models\summit\ISummitRepository;
3433
use models\summit\Summit;
@@ -290,156 +289,157 @@ function () {
290289
*/
291290
public function getAllBySummitCSV($summit_id)
292291
{
293-
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->getResourceServerContext())->find($summit_id);
294-
if (is_null($summit)) return $this->error404();
295-
$questions = $summit->getOrderExtraQuestionsByUsage(SummitOrderExtraQuestionTypeConstants::TicketQuestionUsage);
296-
return $this->_getAllCSV(
297-
function () {
298-
return [
299-
'id' => ['=='],
300-
'not_id' => ['=='],
301-
'number' => ['@@', '=@', '=='],
302-
'order_number' => ['@@', '=@', '=='],
303-
'owner_name' => ['@@', '=@', '=='],
304-
'owner_first_name' => ['@@', '=@', '=='],
305-
'owner_last_name' => ['@@', '=@', '=='],
306-
'owner_email' => ['@@', '=@', '=='],
307-
'owner_company' => ['@@', '=@', '=='],
308-
'summit_id' => ['=='],
309-
'owner_id' => ['=='],
310-
'order_id' => ['=='],
311-
'status' => ['==', '<>'],
312-
'is_active' => ['=='],
313-
'has_requested_refund_requests' => ['=='],
314-
'access_level_type_name' => ['=='],
315-
'access_level_type_id' => ['=='],
316-
'ticket_type_id' => ['=='],
317-
'has_owner' => ['=='],
318-
'owner_status' => ['=='],
319-
'has_badge' => ['=='],
320-
'view_type_id' => ['=='],
321-
'promo_code_id' => ['=='],
322-
'promo_code' => ['==', '@@', '=@'],
323-
'promo_code_tag' => ['==', '@@', '=@'],
324-
'promo_code_tag_id' => ['=='],
325-
'promo_code_description' => ['@@', '=@'],
326-
'final_amount' => ['==', '<>', '>=', '>'],
327-
'is_printable' => ['=='],
328-
'badge_type_id' => ['=='],
329-
'has_badge_prints' => ['=='],
330-
'badge_prints_count' => ['==', '>=', '<=', '>', '<'],
331-
'has_owner_company' => ['=='],
332-
'exclude_is_printable_free_unassigned' => ['=='],
333-
];
334-
},
335-
function () {
336-
return [
337-
'id' => 'sometimes|integer',
338-
'not_id' => 'sometimes|integer',
339-
'status' => sprintf('sometimes|in:%s', implode(',', IOrderConstants::ValidStatus)),
340-
'number' => 'sometimes|string',
341-
'order_number' => 'sometimes|string',
342-
'owner_name' => 'sometimes|string',
343-
'owner_first_name' => 'sometimes|string',
344-
'owner_last_name' => 'sometimes|string',
345-
'owner_email' => 'sometimes|string',
346-
'owner_company' => 'sometimes|string',
347-
'summit_id' => 'sometimes|integer',
348-
'owner_id' => 'sometimes|integer',
349-
'order_id' => 'sometimes|integer',
350-
'is_active' => 'sometimes|boolean',
351-
'has_requested_refund_requests' => 'sometimes|boolean',
352-
'access_level_type_name' => 'sometimes|string',
353-
'access_level_type_id' => 'sometimes|integer',
354-
'ticket_type_id' => 'sometimes|integer',
355-
'has_owner' => 'sometimes|boolean',
356-
'owner_status' => 'sometimes|string|in:' . implode(',', SummitAttendee::AllowedStatus),
357-
'has_badge' => 'sometimes|boolean',
358-
'view_type_id' => 'sometimes|integer',
359-
'promo_code_id' => 'sometimes|integer',
360-
'promo_code' => 'sometimes|string',
361-
'promo_code_tag' => 'sometimes|string',
362-
'promo_code_description' => 'sometimes|string',
363-
'promo_code_tag_id' => 'sometimes|integer',
364-
'final_amount' => 'sometimes|numeric',
365-
'is_printable' => ['sometimes', new Boolean()],
366-
'badge_type_id' => 'sometimes|integer',
367-
'has_badge_prints' => ['sometimes', new Boolean()],
368-
'badge_prints_count' => 'sometimes|integer',
369-
'has_owner_company' => ['sometimes', new Boolean()],
370-
'exclude_is_printable_free_unassigned' => ['sometimes', new Boolean()],
371-
];
372-
},
373-
function () {
374-
return [
375-
'id',
376-
'number',
377-
'status',
378-
'owner_name',
379-
'owner_first_name',
380-
'owner_last_name',
381-
'ticket_type',
382-
'final_amount',
383-
'owner_email',
384-
'owner_company',
385-
'promo_code',
386-
'bought_date',
387-
'refunded_amount',
388-
'final_amount_adjusted',
389-
'badge_type_id',
390-
'badge_type',
391-
'badge_prints_count',
392-
'created',
393-
];
394-
},
395-
function ($filter) use ($summit) {
396-
if ($filter instanceof Filter) {
397-
$filter->addFilterCondition(FilterElement::makeEqual('summit_id', $summit->getId()));
398-
}
399-
return $filter;
400-
},
401-
function () {
402-
return SerializerRegistry::SerializerType_CSV;
403-
},
404-
function () use($summit) {
405-
return [
406-
'created' => new EpochCellFormatter(EpochCellFormatter::DefaultFormat, $summit->getTimeZone()),
407-
'last_edited' => new EpochCellFormatter(EpochCellFormatter::DefaultFormat, $summit->getTimeZone()),
408-
'purchase_date' => new EpochCellFormatter(EpochCellFormatter::DefaultFormat, $summit->getTimeZone()),
409-
'attendee_checked_in' => new BooleanCellFormatter(),
410-
'is_active' => new BooleanCellFormatter(),
411-
];
412-
},
413-
function () use ($summit) {
414-
$allowed_columns = [
415-
'id',
416-
'created',
417-
'last_edited',
418-
'number',
419-
'status',
420-
'attendee_id',
421-
'attendee_first_name',
422-
'attendee_last_name',
423-
'attendee_email',
424-
'attendee_company',
425-
'external_order_id',
426-
'external_attendee_id',
427-
'purchase_date',
428-
'ticket_type_id',
429-
'ticket_type_name',
430-
'order_id',
431-
'badge_id',
432-
'promo_code_id',
433-
'promo_code',
434-
'raw_cost',
435-
'final_amount',
436-
'discount',
437-
'refunded_amount',
438-
'currency',
439-
'badge_type_id',
440-
'badge_type_name',
441-
'promo_code_tags',
442-
];
292+
return $this->withReplica(function() use ($summit_id) {
293+
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->getResourceServerContext())->find($summit_id);
294+
if (is_null($summit)) return $this->error404();
295+
$questions = $summit->getOrderExtraQuestionsByUsage(SummitOrderExtraQuestionTypeConstants::TicketQuestionUsage);
296+
return $this->_getAllCSV(
297+
function () {
298+
return [
299+
'id' => ['=='],
300+
'not_id' => ['=='],
301+
'number' => ['@@', '=@', '=='],
302+
'order_number' => ['@@', '=@', '=='],
303+
'owner_name' => ['@@', '=@', '=='],
304+
'owner_first_name' => ['@@', '=@', '=='],
305+
'owner_last_name' => ['@@', '=@', '=='],
306+
'owner_email' => ['@@', '=@', '=='],
307+
'owner_company' => ['@@', '=@', '=='],
308+
'summit_id' => ['=='],
309+
'owner_id' => ['=='],
310+
'order_id' => ['=='],
311+
'status' => ['==', '<>'],
312+
'is_active' => ['=='],
313+
'has_requested_refund_requests' => ['=='],
314+
'access_level_type_name' => ['=='],
315+
'access_level_type_id' => ['=='],
316+
'ticket_type_id' => ['=='],
317+
'has_owner' => ['=='],
318+
'owner_status' => ['=='],
319+
'has_badge' => ['=='],
320+
'view_type_id' => ['=='],
321+
'promo_code_id' => ['=='],
322+
'promo_code' => ['==', '@@', '=@'],
323+
'promo_code_tag' => ['==', '@@', '=@'],
324+
'promo_code_tag_id' => ['=='],
325+
'promo_code_description' => ['@@', '=@'],
326+
'final_amount' => ['==', '<>', '>=', '>'],
327+
'is_printable' => ['=='],
328+
'badge_type_id' => ['=='],
329+
'has_badge_prints' => ['=='],
330+
'badge_prints_count' => ['==', '>=', '<=', '>', '<'],
331+
'has_owner_company' => ['=='],
332+
'exclude_is_printable_free_unassigned' => ['=='],
333+
];
334+
},
335+
function () {
336+
return [
337+
'id' => 'sometimes|integer',
338+
'not_id' => 'sometimes|integer',
339+
'status' => sprintf('sometimes|in:%s', implode(',', IOrderConstants::ValidStatus)),
340+
'number' => 'sometimes|string',
341+
'order_number' => 'sometimes|string',
342+
'owner_name' => 'sometimes|string',
343+
'owner_first_name' => 'sometimes|string',
344+
'owner_last_name' => 'sometimes|string',
345+
'owner_email' => 'sometimes|string',
346+
'owner_company' => 'sometimes|string',
347+
'summit_id' => 'sometimes|integer',
348+
'owner_id' => 'sometimes|integer',
349+
'order_id' => 'sometimes|integer',
350+
'is_active' => 'sometimes|boolean',
351+
'has_requested_refund_requests' => 'sometimes|boolean',
352+
'access_level_type_name' => 'sometimes|string',
353+
'access_level_type_id' => 'sometimes|integer',
354+
'ticket_type_id' => 'sometimes|integer',
355+
'has_owner' => 'sometimes|boolean',
356+
'owner_status' => 'sometimes|string|in:' . implode(',', SummitAttendee::AllowedStatus),
357+
'has_badge' => 'sometimes|boolean',
358+
'view_type_id' => 'sometimes|integer',
359+
'promo_code_id' => 'sometimes|integer',
360+
'promo_code' => 'sometimes|string',
361+
'promo_code_tag' => 'sometimes|string',
362+
'promo_code_description' => 'sometimes|string',
363+
'promo_code_tag_id' => 'sometimes|integer',
364+
'final_amount' => 'sometimes|numeric',
365+
'is_printable' => ['sometimes', new Boolean()],
366+
'badge_type_id' => 'sometimes|integer',
367+
'has_badge_prints' => ['sometimes', new Boolean()],
368+
'badge_prints_count' => 'sometimes|integer',
369+
'has_owner_company' => ['sometimes', new Boolean()],
370+
'exclude_is_printable_free_unassigned' => ['sometimes', new Boolean()],
371+
];
372+
},
373+
function () {
374+
return [
375+
'id',
376+
'number',
377+
'status',
378+
'owner_name',
379+
'owner_first_name',
380+
'owner_last_name',
381+
'ticket_type',
382+
'final_amount',
383+
'owner_email',
384+
'owner_company',
385+
'promo_code',
386+
'bought_date',
387+
'refunded_amount',
388+
'final_amount_adjusted',
389+
'badge_type_id',
390+
'badge_type',
391+
'badge_prints_count',
392+
'created',
393+
];
394+
},
395+
function ($filter) use ($summit) {
396+
if ($filter instanceof Filter) {
397+
$filter->addFilterCondition(FilterElement::makeEqual('summit_id', $summit->getId()));
398+
}
399+
return $filter;
400+
},
401+
function () {
402+
return SerializerRegistry::SerializerType_CSV;
403+
},
404+
function () use($summit) {
405+
return [
406+
'created' => new EpochCellFormatter(EpochCellFormatter::DefaultFormat, $summit->getTimeZone()),
407+
'last_edited' => new EpochCellFormatter(EpochCellFormatter::DefaultFormat, $summit->getTimeZone()),
408+
'purchase_date' => new EpochCellFormatter(EpochCellFormatter::DefaultFormat, $summit->getTimeZone()),
409+
'attendee_checked_in' => new BooleanCellFormatter(),
410+
'is_active' => new BooleanCellFormatter(),
411+
];
412+
},
413+
function () use ($summit) {
414+
$allowed_columns = [
415+
'id',
416+
'created',
417+
'last_edited',
418+
'number',
419+
'status',
420+
'attendee_id',
421+
'attendee_first_name',
422+
'attendee_last_name',
423+
'attendee_email',
424+
'attendee_company',
425+
'external_order_id',
426+
'external_attendee_id',
427+
'purchase_date',
428+
'ticket_type_id',
429+
'ticket_type_name',
430+
'order_id',
431+
'badge_id',
432+
'promo_code_id',
433+
'promo_code',
434+
'raw_cost',
435+
'final_amount',
436+
'discount',
437+
'refunded_amount',
438+
'currency',
439+
'badge_type_id',
440+
'badge_type_name',
441+
'promo_code_tags',
442+
];
443443

444444
foreach ($summit->getBadgeFeaturesTypes() as $featuresType) {
445445
$allowed_columns[] = $featuresType->getName();
@@ -449,41 +449,42 @@ function () use ($summit) {
449449
$allowed_columns[] = $question->getLabel();
450450
}
451451

452-
$columns_param = Request::input("columns", "");
453-
$columns = [];
454-
if (!empty($columns_param))
455-
$columns = explode(',', $columns_param);
456-
$diff = array_diff($columns, $allowed_columns);
457-
if (count($diff) > 0) {
458-
throw new ValidationException(sprintf("columns %s are not allowed!", implode(",", $diff)));
459-
}
460-
if (empty($columns))
461-
$columns = $allowed_columns;
462-
return $columns;
463-
},
464-
sprintf('tickets-%s-', $summit_id),
465-
[
466-
'features_types' => $summit->getBadgeFeaturesTypes(),
467-
'ticket_questions' => $questions
468-
],
469-
null,
470-
function($data, $serializerParams) use($questions){
471-
472-
$owners = [];
473-
foreach ($data->getItems() as $t){
474-
if ($t->hasOwner()) $owners[] = $t->getOwner()->getId();
475-
}
476-
$questionIds = [];
477-
foreach ($questions as $q) {
478-
$questionIds[] = $q->getId();
479-
}
480-
$questionIds = array_values(array_unique($questionIds));
481-
$owners = array_values(array_unique($owners));
452+
$columns_param = Request::input("columns", "");
453+
$columns = [];
454+
if (!empty($columns_param))
455+
$columns = explode(',', $columns_param);
456+
$diff = array_diff($columns, $allowed_columns);
457+
if (count($diff) > 0) {
458+
throw new ValidationException(sprintf("columns %s are not allowed!", implode(",", $diff)));
459+
}
460+
if (empty($columns))
461+
$columns = $allowed_columns;
462+
return $columns;
463+
},
464+
sprintf('tickets-%s-', $summit_id),
465+
[
466+
'features_types' => $summit->getBadgeFeaturesTypes(),
467+
'ticket_questions' => $questions
468+
],
469+
null,
470+
function($data, $serializerParams) use($questions){
471+
472+
$owners = [];
473+
foreach ($data->getItems() as $t){
474+
if ($t->hasOwner()) $owners[] = $t->getOwner()->getId();
475+
}
476+
$questionIds = [];
477+
foreach ($questions as $q) {
478+
$questionIds[] = $q->getId();
479+
}
480+
$questionIds = array_values(array_unique($questionIds));
481+
$owners = array_values(array_unique($owners));
482482

483-
$serializerParams['answers_by_owner'] = $this->attendee_repository->getExtraQuestionAnswersByOwners($owners, $questionIds);
484-
return $serializerParams;
485-
}
486-
);
483+
$serializerParams['answers_by_owner'] = $this->attendee_repository->getExtraQuestionAnswersByOwners($owners, $questionIds);
484+
return $serializerParams;
485+
}
486+
);
487+
});
487488
}
488489

489490
/**
@@ -979,4 +980,4 @@ public function canPrintAttendeeBadge($summit_id, $ticket_id, $view_type)
979980
);
980981
});
981982
}
982-
}
983+
}

0 commit comments

Comments
 (0)