diff --git a/db/seeds/SponsorTickets.php b/db/seeds/SponsorTickets.php new file mode 100644 index 000000000..d577f5da6 --- /dev/null +++ b/db/seeds/SponsorTickets.php @@ -0,0 +1,69 @@ +execute(sprintf( + "DELETE FROM afup_forum_sponsors_tickets WHERE token IN ('%s', '%s', '%s')", + self::TOKEN_GREEN, + self::TOKEN_ORANGE, + self::TOKEN_RED, + )); + + $data = [ + [ + 'id' => 101, + 'company' => 'Sponsor Zéro Utilisé', + 'token' => self::TOKEN_GREEN, + 'contact_email' => 'vert@sponsor-test.com', + 'max_invitations' => 4, + 'used_invitations' => 0, + 'id_forum' => Event::ID_FORUM, + 'created_on' => $now->format('Y-m-d H:i:s'), + 'edited_on' => $now->format('Y-m-d H:i:s'), + 'creator_id' => Users::ID_USER_ADMIN, + 'qr_codes_scanner_available' => 0, + ], + [ + 'id' => 102, + 'company' => 'Sponsor Deux Tiers Utilisé', + 'token' => self::TOKEN_ORANGE, + 'contact_email' => 'deuxtiers@sponsor-test.com', + 'max_invitations' => 3, + 'used_invitations' => 2, + 'id_forum' => Event::ID_FORUM, + 'created_on' => $now->format('Y-m-d H:i:s'), + 'edited_on' => $now->format('Y-m-d H:i:s'), + 'creator_id' => Users::ID_USER_ADMIN, + 'qr_codes_scanner_available' => 0, + ], + [ + 'id' => 103, + 'company' => 'Sponsor Complet', + 'token' => self::TOKEN_RED, + 'contact_email' => 'complet@sponsor-test.com', + 'max_invitations' => 1, + 'used_invitations' => 1, + 'id_forum' => Event::ID_FORUM, + 'created_on' => $now->format('Y-m-d H:i:s'), + 'edited_on' => $now->format('Y-m-d H:i:s'), + 'creator_id' => Users::ID_USER_ADMIN, + 'qr_codes_scanner_available' => 0, + ], + ]; + + $this->table('afup_forum_sponsors_tickets')->insert($data)->saveData(); + } +} diff --git a/templates/admin/event/sponsor_ticket.html.twig b/templates/admin/event/sponsor_ticket.html.twig index c1f6e9efc..71b1959b2 100644 --- a/templates/admin/event/sponsor_ticket.html.twig +++ b/templates/admin/event/sponsor_ticket.html.twig @@ -47,6 +47,7 @@ Token Invitations totales Invitations utilisées + Tokens restants Peut scanner QR Codes @@ -62,6 +63,22 @@ {{ token.token }} {{ token.maxInvitations }} {{ token.usedInvitations }} + + {% set pending = token.pendingInvitations %} + {% if token.maxInvitations > 0 %} + {% set remainingRate = pending / token.maxInvitations %} + {% else %} + {% set remainingRate = 0 %} + {% endif %} + {% if remainingRate > 0.5 %} + {% set color = 'red' %} + {% elseif remainingRate == 0 %} + {% set color = 'green' %} + {% else %} + {% set color = 'orange' %} + {% endif %} + {{ (remainingRate * 100)|round }}% + {% if token.qrCodesScannerAvailable %}OUI{% else %}-{% endif %}