Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display additional info at check in #1434

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/main/java/alfio/manager/CheckInManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,8 @@ public TicketAndCheckInResult checkIn(int eventId, String ticketIdentifier, Opti
TicketWithCategory ticket = descriptor.getTicket();
scanAuditRepository.insert(ticketIdentifier, eventId, ZonedDateTime.now(clockProvider.getClock()), user, SUCCESS, ScanAudit.Operation.SCAN);
auditingRepository.insert(ticket.getTicketsReservationId(), userRepository.findIdByUserName(user).orElse(null), eventId, CHECK_IN, new Date(), Audit.EntityType.TICKET, Integer.toString(descriptor.getTicket().getId()));
// return also additional items, if any
return new SuccessfulCheckIn(ticket, getAdditionalServicesForTicket(ticket, event), loadBoxColor(ticket));
// return also additional items and any additional info to display.
return new SuccessfulCheckIn(ticket, getAdditionalServicesForTicket(ticket, event), purchaseContextFieldRepository.findValuesForTicketAtCheckIn(ticket.getId()), loadBoxColor(ticket));
} else if(checkInStatus == BADGE_SCAN_ALREADY_DONE || checkInStatus == OK_READY_FOR_BADGE_SCAN) {
var auditingStatus = checkInStatus == OK_READY_FOR_BADGE_SCAN ? BADGE_SCAN_SUCCESS : checkInStatus;
scanAuditRepository.insert(ticketIdentifier, eventId, ZonedDateTime.now(clockProvider.getClock()), user, auditingStatus, ScanAudit.Operation.SCAN);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/alfio/manager/PurchaseContextFieldManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,13 @@ public void insertAdditionalField(PurchaseContext purchaseContext, AdditionalFie
}

long configurationId = purchaseContextFieldRepository.insertConfiguration(eventIdOrNull(purchaseContext), purchaseContext.getOrganizationId(), descriptorIdOrNull(purchaseContext), f.getName(), order, f.getType(), serializedRestrictedValues,
f.getMaxLength(), f.getMinLength(), f.isRequired(), context, additionalServiceId, generateJsonForList(f.getLinkedCategoriesIds())).getKey();
f.getMaxLength(), f.getMinLength(), f.isRequired(), context, additionalServiceId, generateJsonForList(f.getLinkedCategoriesIds()), f.isDisplayAtCheckIn()).getKey();
f.getDescription().forEach((locale, value) -> purchaseContextFieldRepository.insertDescription(configurationId, locale, Json.GSON.toJson(value), purchaseContext.getOrganizationId()));
}

public void updateAdditionalField(long id, EventModification.UpdateAdditionalField f, int organizationId) {
String serializedRestrictedValues = toSerializedRestrictedValues(f);
purchaseContextFieldRepository.updateField(id, f.isRequired(), !f.isReadOnly(), serializedRestrictedValues, toSerializedDisabledValues(f), generateJsonForList(f.getLinkedCategoriesIds()));
purchaseContextFieldRepository.updateField(id, f.isRequired(), !f.isReadOnly(), serializedRestrictedValues, toSerializedDisabledValues(f), generateJsonForList(f.getLinkedCategoriesIds()), f.isDisplayAtCheckIn());
f.getDescription().forEach((locale, value) -> {
String val = Json.GSON.toJson(value.getDescription());
if(0 == purchaseContextFieldRepository.updateDescription(id, locale, val)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,8 @@
package alfio.manager.support;

import alfio.model.AdditionalServiceFieldValue;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

import java.util.List;

@Getter
@RequiredArgsConstructor
public class AdditionalServiceInfo {
private final String name;
private final int count;
private final List<AdditionalServiceFieldValue> fields;
public record AdditionalServiceInfo(String name, int count, List<AdditionalServiceFieldValue> fields) {
}
8 changes: 8 additions & 0 deletions src/main/java/alfio/manager/support/SuccessfulCheckIn.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/
package alfio.manager.support;

import alfio.model.FieldValueAndDescription;
import alfio.model.TicketWithCategory;

import java.util.List;
Expand All @@ -24,14 +25,17 @@

public class SuccessfulCheckIn extends TicketAndCheckInResult {
private final List<AdditionalServiceInfo> additionalServices;
private final List<FieldValueAndDescription> fieldsToDisplay;
private final String boxColor;

public SuccessfulCheckIn(TicketWithCategory ticket,
List<AdditionalServiceInfo> additionalServices,
List<FieldValueAndDescription> fieldsToDisplay,
String boxColor) {
super(ticket, new DefaultCheckInResult(SUCCESS, "success"));
this.additionalServices = additionalServices;
this.boxColor = boxColor;
this.fieldsToDisplay = fieldsToDisplay;
}

public List<AdditionalServiceInfo> getAdditionalServices() {
Expand All @@ -41,4 +45,8 @@ public List<AdditionalServiceInfo> getAdditionalServices() {
public String getBoxColor() {
return boxColor;
}

public List<FieldValueAndDescription> getFieldsToDisplay() {
return fieldsToDisplay;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public enum Context {
private final Integer additionalServiceId;
private final List<Integer> categoryIds;
private final List<String> disabledValues;
private final boolean displayAtCheckIn;


public PurchaseContextFieldConfiguration(@Column("id") int id,
Expand All @@ -66,7 +67,8 @@ public PurchaseContextFieldConfiguration(@Column("id") int id,
@Column("context") Context context,
@Column("additional_service_id") Integer additionalServiceId,
@Column("ticket_category_ids") String ticketCategoryIds,
@Column("field_disabled_values") String disabledValues) {
@Column("field_disabled_values") String disabledValues,
@Column("display_at_check_in") boolean displayAtCheckIn) {
this.id = id;
this.eventId = eventId;
this.subscriptionDescriptorId = subscriptionDescriptorId;
Expand All @@ -82,6 +84,7 @@ public PurchaseContextFieldConfiguration(@Column("id") int id,
this.context = context;
this.additionalServiceId = additionalServiceId;
this.categoryIds = ticketCategoryIds == null ? Collections.emptyList() : Json.GSON.fromJson(ticketCategoryIds, new TypeToken<List<Integer>>(){}.getType());
this.displayAtCheckIn = displayAtCheckIn;
}

public boolean isInputField() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public class AdditionalInfoRequest {
private List<DescriptionRequest> placeholder;
private List<RestrictedValueRequest> restrictedValues;
private ContentLengthRequest contentLength;
private Boolean displayAtCheckIn;

public boolean isValid() {
return StringUtils.isNotBlank(name)
Expand Down Expand Up @@ -77,7 +78,9 @@ public AdditionalFieldRequest toAdditionalField(int ordinal) {
restrictedValueList,
toDescriptionMap(EventCreationRequest.orEmpty(label), EventCreationRequest.orEmpty(placeholder), EventCreationRequest.orEmpty(this.restrictedValues)),
null,
null);
null,
displayAtCheckIn
);
}

private static Map<String, EventModification.Description> toDescriptionMap(List<DescriptionRequest> label,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public class AdditionalFieldRequest implements EventModification.WithRestrictedV
private final Map<String, EventModification.Description> description;
private final EventModification.AdditionalService linkedAdditionalService;
private final List<Integer> linkedCategoryIds;
private final boolean displayAtCheckIn;


@JsonCreator
Expand All @@ -56,7 +57,8 @@ public AdditionalFieldRequest(@JsonProperty("order") int order,
@JsonProperty("restrictedValues") List<EventModification.RestrictedValue> restrictedValues,
@JsonProperty("description") Map<String, EventModification.Description> description,
@JsonProperty("forAdditionalService") EventModification.AdditionalService linkedAdditionalService,
@JsonProperty("categoryIds") List<Integer> linkedCategoryIds) {
@JsonProperty("categoryIds") List<Integer> linkedCategoryIds,
@JsonProperty("displayAtCheckIn") Boolean displayAtCheckIn) {
this.order = order;
this.useDefinedOrder = Boolean.TRUE.equals(useDefinedOrder);
this.name = name;
Expand All @@ -69,6 +71,7 @@ public AdditionalFieldRequest(@JsonProperty("order") int order,
this.description = description;
this.linkedAdditionalService = linkedAdditionalService;
this.linkedCategoryIds = linkedCategoryIds;
this.displayAtCheckIn = Boolean.TRUE.equals(displayAtCheckIn);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ public static class UpdateAdditionalField implements WithRestrictedValues, WithL
private final Map<String, TicketFieldDescriptionModification> description;
private final List<String> disabledValues;
private final List<Integer> linkedCategoriesIds;
private final boolean displayAtCheckIn;

@JsonCreator
public UpdateAdditionalField(@JsonProperty("type") String type,
Expand All @@ -189,14 +190,16 @@ public UpdateAdditionalField(@JsonProperty("type") String type,
@JsonProperty("restrictedValues") List<String> restrictedValues,
@JsonProperty("disabledValues") List<String> disabledValues,
@JsonProperty("description") Map<String, TicketFieldDescriptionModification> description,
@JsonProperty("categoryIds") List<Integer> linkedCategoriesIds) {
@JsonProperty("categoryIds") List<Integer> linkedCategoriesIds,
@JsonProperty("displayAtCheckIn") Boolean displayAtCheckIn) {
this.type = type;
this.required = required;
this.readOnly = readOnly;
this.restrictedValues = restrictedValues;
this.disabledValues = disabledValues;
this.description = description;
this.linkedCategoriesIds = linkedCategoriesIds;
this.displayAtCheckIn = Boolean.TRUE.equals(displayAtCheckIn);
}

@Override
Expand Down
21 changes: 16 additions & 5 deletions src/main/java/alfio/repository/FieldRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
interface FieldRepository {

@Query("""
insert into purchase_context_field_configuration(event_id_fk, organization_id_fk, subscription_descriptor_id_fk, field_name, field_order, field_type, field_restricted_values, field_maxlength, field_minlength, field_required, context, additional_service_id, ticket_category_ids) \
values (:eventId, :organizationId, :subscriptionDescriptorId, :name, :order, :type, :restrictedValues, :maxLength, :minLength, :required, :context::ADDITIONAL_FIELD_CONTEXT, :additionalServiceId, :categoryIds)\
insert into purchase_context_field_configuration(event_id_fk, organization_id_fk, subscription_descriptor_id_fk, field_name, field_order, field_type, field_restricted_values, field_maxlength, field_minlength, field_required, context, additional_service_id, ticket_category_ids, display_at_check_in) \
values (:eventId, :organizationId, :subscriptionDescriptorId, :name, :order, :type, :restrictedValues, :maxLength, :minLength, :required, :context::ADDITIONAL_FIELD_CONTEXT, :additionalServiceId, :categoryIds, :displayAtCheckIn)\
""")
@AutoGeneratedKey("id")
AffectedRowCountAndKey<Long> insertConfiguration(@Bind("eventId") Integer eventId,
Expand All @@ -43,15 +43,26 @@ AffectedRowCountAndKey<Long> insertConfiguration(@Bind("eventId") Integer eventI
@Bind("required") boolean required,
@Bind("context") PurchaseContextFieldConfiguration.Context context,
@Bind("additionalServiceId") Integer additionalServiceId,
@Bind("categoryIds") String categoryIdsJson);
@Bind("categoryIds") String categoryIdsJson,
@Bind("displayAtCheckIn") boolean displayAtCheckIn);

@Query("update purchase_context_field_configuration set field_required = :required, field_editable = :editable, field_restricted_values = :restrictedValues, field_disabled_values = :disabledValues, ticket_category_ids = :categoryIds where id = :id")
@Query("""
update purchase_context_field_configuration set
field_required = :required,
field_editable = :editable,
field_restricted_values = :restrictedValues,
field_disabled_values = :disabledValues,
ticket_category_ids = :categoryIds,
display_at_check_in = :displayAtCheckIn
where id = :id
""")
int updateField(@Bind("id") long id,
@Bind("required") boolean required,
@Bind("editable") boolean editable,
@Bind("restrictedValues") String restrictedValues,
@Bind("disabledValues") String disabledValues,
@Bind("categoryIds") String linkedCategoryIds);
@Bind("categoryIds") String linkedCategoryIds,
@Bind("displayAtCheckIn") boolean displayAtCheckIn);

@Query("""
insert into purchase_context_field_description(field_configuration_id_fk, field_locale, description, organization_id_fk)\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,15 @@ List<PurchaseContextFieldValue> findAllForContextByTicketId(@Bind("ticketId") in
" where ticket_id_fk = :ticketId and field_name in (:fieldNames)")
List<FieldValueAndDescription> findValueForTicketId(@Bind("ticketId") int id, @Bind("fieldNames") Set<String> fieldNames);

/**
* Returns **only** info that don't belong already to an additional item.
* @param id ticketId
* @return List of FieldValueAndDescription
*/
@Query("select "+FIELD_VALUE_COLUMNS+", description from all_ticket_field_values " +
" where ticket_id_fk = :ticketId and display_at_check_in = true and additional_service_item_id_fk is null")
List<FieldValueAndDescription> findValuesForTicketAtCheckIn(@Bind("ticketId") int id);

@Query("update purchase_context_field_value set field_value = :value where " + TICKET_ID_OR_SUBSCRIPTION_ID +
" and field_configuration_id_fk = :fieldConfigurationId")
int updateValue(@Bind("ticketId") Integer ticketId,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
--
-- This file is part of alf.io.
--
-- alf.io is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- alf.io is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with alf.io. If not, see <http://www.gnu.org/licenses/>.
--

alter table purchase_context_field_configuration add column display_at_check_in BOOLEAN not null default false;

Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ create view field_value_w_additional as (
b.field_name as field_name,
a.field_value as field_value,
b.field_type as field_type,
b.context as context
b.context as context,
b.display_at_check_in as display_at_check_in
from purchase_context_field_value a
join purchase_context_field_configuration b on a.field_configuration_id_fk = b.id
where (a.ticket_id_fk is not null and a.context = 'ATTENDEE')
Expand All @@ -55,7 +56,8 @@ create view field_value_w_additional as (
tfc.field_name as field_name,
coalesce(asv.field_value, '') as field_value,
tfc.field_type as field_type,
asv.context as context
asv.context as context,
tfc.display_at_check_in as display_at_check_in
from purchase_context_field_value asv
join additional_service_item item on asv.additional_service_item_id_fk = item.id
join purchase_context_field_configuration tfc on tfc.id = asv.field_configuration_id_fk
Expand All @@ -70,7 +72,8 @@ create view all_ticket_field_values as (
a.field_name,
a.field_value,
null as description,
a.context as context
a.context as context,
a.display_at_check_in
from field_value_w_additional a
where a.field_type <> 'select'
union all
Expand All @@ -81,7 +84,8 @@ create view all_ticket_field_values as (
a.field_name,
a.field_value,
c.description,
a.context as context
a.context as context,
a.display_at_check_in
from field_value_w_additional a
inner join ticket on a.ticket_id_fk = ticket.id
left join purchase_context_field_description c on c.field_configuration_id_fk = a.field_configuration_id_fk
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ <h5 class="text-muted">The following data will be collected <span data-ng-if="$c
<div class="col-sm-4"><strong>Read Only</strong></div>
<div class="col-sm-8">{{field.readOnly}}</div>
</div>
<div class="row">
<div class="col-sm-4" uib-tooltip="When enabled, this information will be visible to the check-in staff.">
<strong>Show at Check-in</strong>
<i class="fa fa-info-circle" ></i>
</div>
<div class="col-sm-8">{{field.displayAtCheckIn ? 'yes' : 'no'}}</div>
</div>
</div>
</div>
<hr data-ng-if="field.type == 'select' || field.type == 'country'" />
Expand Down
Loading
Loading