diff --git a/db/pf-schema-X.Y.sql b/db/pf-schema-X.Y.sql index e0a62122e850..6e084d854a54 100644 --- a/db/pf-schema-X.Y.sql +++ b/db/pf-schema-X.Y.sql @@ -76,6 +76,7 @@ CREATE TABLE person ( `psk` varchar(255) NULL DEFAULT NULL, `potd` enum('no','yes') NOT NULL DEFAULT 'no', `otp` MEDIUMTEXT NULL DEFAULT NULL, + `sponsored_date` DATETIME DEFAULT NULL, PRIMARY KEY (`pid`) ) ENGINE=InnoDB DEFAULT CHARACTER SET = 'utf8mb4'; diff --git a/db/upgrade-X.X-X.Y.sql b/db/upgrade-X.X-X.Y.sql index e3a1f408ef6d..38d62c9a7297 100644 --- a/db/upgrade-X.X-X.Y.sql +++ b/db/upgrade-X.X-X.Y.sql @@ -49,6 +49,10 @@ call ValidateVersion; DROP PROCEDURE IF EXISTS ValidateVersion; +\! echo "Updating the person table" +ALTER TABLE person + ADD COLUMN IF NOT EXISTS sponsored_date DATETIME DEFAULT NULL; + -- -- UPGRADE STATEMENTS GO HERE -- diff --git a/html/captive-portal/lib/captiveportal/PacketFence/DynamicRouting/Module/Authentication/Sponsor.pm b/html/captive-portal/lib/captiveportal/PacketFence/DynamicRouting/Module/Authentication/Sponsor.pm index ceab559dc4b2..4611b046bac9 100644 --- a/html/captive-portal/lib/captiveportal/PacketFence/DynamicRouting/Module/Authentication/Sponsor.pm +++ b/html/captive-portal/lib/captiveportal/PacketFence/DynamicRouting/Module/Authentication/Sponsor.pm @@ -181,8 +181,8 @@ sub do_sponsor_registration { return unless($self->_validate_sponsor($sponsor)); # form valid, adding person (using modify in case person already exists) - my $note = 'sponsored confirmation Date of arrival: ' . time2str("%Y-%m-%d %H:%M:%S", time); - $logger->info( "Adding guest person $pid" ); + my $sponsored_date = time2str("%Y-%m-%d %H:%M:%S", time); + $logger->info( "Adding guest person $pid Date of arrival: $sponsored_date"); $info{'bcc'} = $source->{sponsorship_bcc}; $info{'activation_domain'} = $source->{activation_domain} if (defined($source->{activation_domain})); @@ -250,10 +250,10 @@ sub do_sponsor_registration { # update sponsor field with forced_sponsor value if (!defined($self->request_fields->{sponsor})) { - $self->update_person_from_fields(additionnal_fields => {notes => $note, sponsor => $sponsor}); + $self->update_person_from_fields(additionnal_fields => {sponsored_date => $sponsored_date, sponsor => $sponsor}); } else { - $self->update_person_from_fields(additionnal_fields => {notes => $note}); + $self->update_person_from_fields(additionnal_fields => {sponsored_date => $sponsored_date}); } $self->waiting_room(); diff --git a/html/pfappserver/root/src/views/Users/_components/TheFormUpdate.vue b/html/pfappserver/root/src/views/Users/_components/TheFormUpdate.vue index eca3cac2d768..b5ff57d806b0 100644 --- a/html/pfappserver/root/src/views/Users/_components/TheFormUpdate.vue +++ b/html/pfappserver/root/src/views/Users/_components/TheFormUpdate.vue @@ -20,6 +20,11 @@ + + @@ -300,6 +305,7 @@ import { FormGroupLoginRemaining, FormGroupEmail, FormGroupSponsor, + FormGroupSponsoredDate, FormGroupLanguage, FormGroupGender, FormGroupTitle, @@ -344,6 +350,7 @@ const components = { FormGroupPid, FormGroupEmail, FormGroupSponsor, + FormGroupSponsoredDate, FormGroupLanguage, FormGroupGender, FormGroupTitle, diff --git a/html/pfappserver/root/src/views/Users/_components/index.js b/html/pfappserver/root/src/views/Users/_components/index.js index d9bd2a0677be..3963c1292428 100644 --- a/html/pfappserver/root/src/views/Users/_components/index.js +++ b/html/pfappserver/root/src/views/Users/_components/index.js @@ -37,6 +37,7 @@ export { BaseFormGroupTextarea as FormGroupAddress, BaseFormGroupInputDateTime as FormGroupAnniversary, BaseFormGroupInputDateTime as FormGroupBirthday, + BaseFormGroupInputDateTime as FormGroupSponsoredDate, BaseFormGroupInput as FormGroupPsk, BaseFormGroupTextarea as FormGroupNotes, BaseFormGroupInput as FormGroupCustomField1, diff --git a/html/pfappserver/root/src/views/Users/_config/index.js b/html/pfappserver/root/src/views/Users/_config/index.js index 9377ef4a8fe2..0a9c925618de 100644 --- a/html/pfappserver/root/src/views/Users/_config/index.js +++ b/html/pfappserver/root/src/views/Users/_config/index.js @@ -46,6 +46,7 @@ export const createSingleForm = { pid: '', email: '', sponsor: '', + sponsored_date: null, password: '', login_remaining: null, gender: '', @@ -153,6 +154,13 @@ export const importFields = [ required: false, validator: validatorFromColumnSchemas(MysqlDatabase.person.sponsor) }, + { + value: 'sponsored_date', + text: i18n.t('Sponsored Date'), + types: [fieldType.DATE], + required: false, + validator: validatorFromColumnSchemas(MysqlDatabase.person.sponsored_date) + }, { value: 'anniversary', text: i18n.t('Anniversary'), diff --git a/html/pfappserver/root/src/views/Users/_search.js b/html/pfappserver/root/src/views/Users/_search.js index 5eafac2036f5..efd800d5ca00 100644 --- a/html/pfappserver/root/src/views/Users/_search.js +++ b/html/pfappserver/root/src/views/Users/_search.js @@ -64,6 +64,12 @@ export const useSearch = makeSearch('users', { searchable: false, sortable: true }, + { + key: 'sponsored_date', + label: 'Sponsored Date', // i18n defer + searchable: false, + sortable: true + }, { key: 'anniversary', label: 'Anniversary', // i18n defer @@ -256,6 +262,11 @@ export const useSearch = makeSearch('users', { text: 'Sponsor', // i18n defer types: [conditionType.SUBSTRING] }, + { + value: 'sponsored_date', + text: 'Sponsored Date', // i18n defer + types: [conditionType.SUBSTRING] + }, { value: 'anniversary', text: 'Anniversary', // i18n defer diff --git a/lib/pf/dal/_person.pm b/lib/pf/dal/_person.pm index 85c478722c40..f949b9b8fd0d 100644 --- a/lib/pf/dal/_person.pm +++ b/lib/pf/dal/_person.pm @@ -67,6 +67,7 @@ BEGIN { psk potd otp + sponsored_date ); %DEFAULTS = ( @@ -104,6 +105,7 @@ BEGIN { psk => undef, potd => 'no', otp => undef, + sponsored_date => undef, ); @INSERTABLE_FIELDS = qw( @@ -141,6 +143,7 @@ BEGIN { psk potd otp + sponsored_date ); %FIELDS_META = ( @@ -352,6 +355,12 @@ BEGIN { is_primary_key => 0, is_nullable => 1, }, + sponsored_date => { + type => 'DATETIME', + is_auto_increment => 0, + is_primary_key => 0, + is_nullable => 1, + }, ); @PRIMARY_KEYS = qw( @@ -393,6 +402,7 @@ BEGIN { person.psk person.potd person.otp + person.sponsored_date ); }