Skip to content

Commit 2e83d76

Browse files
committed
feat: added new col attendee_tags to ticket import
Change-Id: Icf3144943631cb74cc9e055522ed9def9c765a49
1 parent 3f82932 commit 2e83d76

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,7 @@ public function getImportTicketDataTemplate($summit_id)
457457
* attendee_first_name (optional)
458458
* attendee_last_name (optional)
459459
* attendee_company (optional)
460+
* attendee_tags (optional)
460461
* ticket_type_name ( mandatory if id and number are missing)
461462
* ticket_type_id ( mandatory if id and number are missing)
462463
* promo_code_id (optional)
@@ -477,6 +478,7 @@ public function getImportTicketDataTemplate($summit_id)
477478
'attendee_first_name' => '',
478479
'attendee_last_name' => '',
479480
'attendee_company' => '',
481+
'attendee_tags' => '',
480482
'ticket_type_name' => '',
481483
'ticket_type_id' => '',
482484
'promo_code_id' => '',

app/Repositories/Main/DoctrineTagRepository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function getByTag($tag)
5858
->select("t")
5959
->from(\models\main\Tag::class, "t")
6060
->where('UPPER(TRIM(t.tag)) = UPPER(TRIM(:tag))')
61-
->setParameter('tag', $tag)
61+
->setParameter('tag', trim($tag))
6262
->setMaxResults(1)
6363
->getQuery()->getOneOrNullResult();
6464
}

app/Services/Model/Imp/SummitOrderService.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
use models\exceptions\ValidationException;
4747
use models\main\ICompanyRepository;
4848
use models\main\IMemberRepository;
49+
use models\main\ITagRepository;
4950
use models\main\Member;
5051
use models\oauth2\IResourceServerContext;
5152
use models\summit\factories\SummitAttendeeFactory;
@@ -1088,6 +1089,11 @@ final class SummitOrderService
10881089
*/
10891090
private $ticket_finder_strategy_factory;
10901091

1092+
/**
1093+
* @var ITagRepository
1094+
*/
1095+
private $tags_repository;
1096+
10911097
/**
10921098
* @param ISummitTicketTypeRepository $ticket_type_repository
10931099
* @param IMemberRepository $member_repository
@@ -1103,6 +1109,7 @@ final class SummitOrderService
11031109
* @param IFileUploadStrategy $upload_strategy
11041110
* @param IFileDownloadStrategy $download_strategy
11051111
* @param ICompanyRepository $company_repository
1112+
* @param ITagRepository $tags_repository
11061113
* @param ICompanyService $company_service
11071114
* @param ITicketFinderStrategyFactory $ticket_finder_strategy_factory
11081115
* @param ITransactionService $tx_service
@@ -1124,6 +1131,7 @@ public function __construct
11241131
IFileUploadStrategy $upload_strategy,
11251132
IFileDownloadStrategy $download_strategy,
11261133
ICompanyRepository $company_repository,
1134+
ITagRepository $tags_repository,
11271135
ICompanyService $company_service,
11281136
ITicketFinderStrategyFactory $ticket_finder_strategy_factory,
11291137
ITransactionService $tx_service,
@@ -1148,6 +1156,7 @@ public function __construct
11481156
$this->company_repository = $company_repository;
11491157
$this->company_service = $company_service;
11501158
$this->ticket_finder_strategy_factory = $ticket_finder_strategy_factory;
1159+
$this->tags_repository = $tags_repository;
11511160
}
11521161

11531162
/**
@@ -3473,6 +3482,7 @@ public function importTicketData(Summit $summit, UploadedFile $csv_file): void
34733482
* attendee_email ( mandatory if id and number are missing)
34743483
* attendee_first_name (mandatory)
34753484
* attendee_last_name (mandatory)
3485+
* attendee_tags (optional)
34763486
* attendee_company (optional)
34773487
* attendee_company_id (optional)
34783488
* ticket_type_name ( mandatory if id and number are missing)
@@ -3605,8 +3615,18 @@ public function processTicketData(int $summit_id, string $filename)
36053615

36063616
Log::debug(sprintf("SummitOrderService::processTicketData creating attendee with payload %s", json_encode($payload)));
36073617

3618+
36083619
$attendee = SummitAttendeeFactory::build($summit, $payload, $member);
36093620

3621+
if ($reader->hasColumn('attendee_tags')) {
3622+
$tags = explode('|', $row['attendee_tags']);
3623+
$attendee->clearTags();
3624+
foreach ($tags as $tag_val) {
3625+
$tag = $this->tags_repository->getByTag($tag_val);
3626+
if(is_null($tag)) continue;
3627+
$attendee->addTag($tag);
3628+
}
3629+
}
36103630
$this->attendee_repository->add($attendee);
36113631
}
36123632
}

0 commit comments

Comments
 (0)