Skip to content

Commit

Permalink
Add Sponsor Tickets (#1022)
Browse files Browse the repository at this point in the history
* Add new Attendees section

* Tweak styles accordingly

* Add Sponsor Ticket

* Add per-sponsor to the calculations in expenses

* Add Complimentary Tickets as an expense category
  • Loading branch information
renintw committed Sep 11, 2023
1 parent 94985a9 commit fb68423
Show file tree
Hide file tree
Showing 5 changed files with 105 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -187,14 +187,8 @@ tr#row-payment-method label {
}

/* Budget Tool */
.wcb-budget-tool .left {
width: 50%;
float: left;
}

.wcb-budget-tool .right {
width: 50%;
float: left;
.wcb-budget-tool .first-section {
display: flex;
}

.wcb-budget-tool .nav-tab-wrapper svg {
Expand Down Expand Up @@ -419,3 +413,9 @@ tr#row-payment-method label {
color: #aaa;
font-weight: normal;
}

.wcb-budget-attendees,
.wcb-budget-attendees td,
.wcb-budget-attendees th {
border-left: none;
}
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ private static function _get_real_value( float $value, $link, $meta ) {
$count_speakers = (int) current( wp_list_pluck( wp_list_filter( $meta, array( 'name' => 'speakers' ) ), 'value' ) );
$count_volunteers = (int) current( wp_list_pluck( wp_list_filter( $meta, array( 'name' => 'volunteers' ) ), 'value' ) );
$count_organizers = (int) current( wp_list_pluck( wp_list_filter( $meta, array( 'name' => 'organizers' ) ), 'value' ) );
$count_sponsors = (int) current( wp_list_pluck( wp_list_filter( $meta, array( 'name' => 'sponsor-tickets' ) ), 'value' ) );
$count_attendees = (int) current( wp_list_pluck( wp_list_filter( $meta, array( 'name' => 'attendees' ) ), 'value' ) );
$count_days = (int) current( wp_list_pluck( wp_list_filter( $meta, array( 'name' => 'days' ) ), 'value' ) );
$count_tracks = (int) current( wp_list_pluck( wp_list_filter( $meta, array( 'name' => 'tracks' ) ), 'value' ) );
Expand All @@ -230,12 +231,16 @@ private static function _get_real_value( float $value, $link, $meta ) {
return $value * $count_volunteers;
case 'per-organizer':
return $value * $count_organizers;
case 'per-sponsor':
return $value * $count_sponsors;
case 'per-speaker-volunteer':
return $value * $count_speakers + $value * $count_volunteers;
case 'per-speaker-volunteer-organizer':
return $value * $count_speakers + $value * $count_volunteers + $value * $count_organizers;
case 'per-attendee':
return $value * $count_attendees;
case 'per-attendee-sponsor':
return $value * $count_attendees + $value * $count_sponsors;
case 'per-day':
return $value * $count_days;
case 'per-track':
Expand Down Expand Up @@ -274,6 +279,7 @@ private static function _get_default_budget() {
array( 'type' => 'meta', 'name' => 'speakers', 'value' => 0 ),
array( 'type' => 'meta', 'name' => 'volunteers', 'value' => 0 ),
array( 'type' => 'meta', 'name' => 'organizers', 'value' => 0 ),
array( 'type' => 'meta', 'name' => 'sponsor-tickets', 'value' => 0 ),
array( 'type' => 'meta', 'name' => 'currency', 'value' => 'USD' ),
array( 'type' => 'meta', 'name' => 'ticket-price', 'value' => 0 ),

Expand All @@ -284,7 +290,6 @@ private static function _get_default_budget() {

array( 'type' => 'expense', 'category' => 'venue', 'note' => 'Venue', 'amount' => 0 ),
array( 'type' => 'expense', 'category' => 'venue', 'note' => 'Wifi Costs', 'amount' => 0, 'link' => 'per-day' ),
array( 'type' => 'expense', 'category' => 'other', 'note' => 'Comped Tickets', 'amount' => 0 ),
array( 'type' => 'expense', 'category' => 'audio-visual', 'note' => 'Video recording', 'amount' => 0 ),
array( 'type' => 'expense', 'category' => 'audio-visual', 'note' => 'Projector rental', 'amount' => 0 ),
array( 'type' => 'expense', 'category' => 'audio-visual', 'note' => 'Livestream', 'amount' => 0 ),
Expand All @@ -295,6 +300,7 @@ private static function _get_default_budget() {
array( 'type' => 'expense', 'category' => 'food-beverage', 'note' => 'Coffee', 'amount' => 0 ),
array( 'type' => 'expense', 'category' => 'swag', 'note' => 'T-shirts', 'amount' => 0 ),
array( 'type' => 'expense', 'category' => 'speaker-event', 'note' => 'Speakers Dinner', 'amount' => 0, 'link' => 'per-speaker' ),
array( 'type' => 'expense', 'category' => 'comped-tickets', 'note' => 'For speakers, special guests, members of the press, volunteers, etc.', 'amount' => 0 ),
);

$extra_budget_for_next_gen = array(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -580,10 +580,11 @@ public static function get_currencies() {
*/
public static function get_payment_categories() {
$categories = array(
// Changes here may need to be synchronized with `_get_default_budget_og_wordcamp()` or `_get_default_budget_next_gen_wordcamp`.
// Changes here may need to be synchronized with `_get_default_budget()`.
'after-party' => esc_html__( 'After Party', 'wordcamporg' ),
'audio-visual' => esc_html__( 'Audio Visual', 'wordcamporg' ),
'camera-shipping' => esc_html__( 'Camera Shipping', 'wordcamporg' ),
'comped-tickets' => esc_html__( 'Complimentary Tickets', 'wordcamporg' ),
'food-beverages' => esc_html__( 'Food & Beverage', 'wordcamporg' ),
'office-supplies' => esc_html__( 'Office Supplies', 'wordcamporg' ),
'signage-badges' => esc_html__( 'Signage & Badges', 'wordcamporg' ),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ window.wcb = window.wcb || { models: {}, input: [] };
$income = $container.find( '.wcb-income-placeholder' ),
$expense = $container.find( '.wcb-expense-placeholder' ),
$meta = $container.find( '.wcb-meta-placeholder' ),
$attendees = $container.find( '.wcb-attendees-placeholder' ),
$summary = $( '.wcb-summary-placeholder' ),
$form = $( '.wcb-submit-form' );

Expand Down Expand Up @@ -277,7 +278,7 @@ window.wcb = window.wcb || { models: {}, input: [] };
if ( networkStatus.isNextGenWordCamp && ( name === 'days' || name === 'hours' ) ) {
this.model.set( 'name', this.$el.find( '.name' ).val() );
}
if ( _.contains( [ 'attendees', 'days', 'tracks', 'speakers', 'volunteers', 'organizers' ], name ) ) {
if ( _.contains( [ 'attendees', 'days', 'tracks', 'speakers', 'volunteers', 'organizers', 'sponsor-tickets' ], name ) ) {
value = parseInt( value.replace( /[^\d.-]/g, '' ) ) || 0;
} else if ( _.contains( [ 'ticket-price', 'hours' ], name ) ) {
value = parseFloat( value.replace( /[^\d.-]/g, '' ) ) || 0;
Expand Down Expand Up @@ -368,18 +369,28 @@ window.wcb = window.wcb || { models: {}, input: [] };
},

addOne: function( item ) {
var view = new EntryView( { model: item } );

switch ( view.model.get( 'type' ) ) {
case 'expense':
var $c = $expense;
break;
case 'income':
var $c = $income;
break;
case 'meta':
default:
var $c = $meta;
const view = new EntryView( { model: item } );
const type = view.model.get('type');
const name = view.model.get('name');

const typeMappings = {
'expense': $expense,
'income': $income,
'meta': $meta
};

const metaNameMappings = {
'attendees': $attendees,
'speakers': $attendees,
'volunteers': $attendees,
'organizers': $attendees,
'sponsor-tickets': $attendees
};

let $c = typeMappings[type] || $meta; // default to $meta if type is not found

if (type === 'meta' && metaNameMappings[name]) {
$c = metaNameMappings[name];
}

$c.before( view.render().el );
Expand All @@ -404,6 +415,7 @@ window.wcb = window.wcb || { models: {}, input: [] };
'speakers' : networkStatus.isNextGenWordCamp ? 'Facilitators' : 'Speakers',
'volunteers' : 'Volunteers',
'organizers' : 'Organizers',
'sponsor-tickets' : 'Sponsor Tickets',
'currency' : 'Currency',
'ticket-price' : 'Ticket Price',
// Only exists in the Central Network.
Expand Down Expand Up @@ -455,6 +467,17 @@ window.wcb = window.wcb || { models: {}, input: [] };
},
},

'per-sponsor' : {
'label' : 'per sponsor',
'hasValue' : true,
'callback' : function( value ) {
return parseFloat( value ) * parseInt( wcb.table.collection.findWhere( {
type : 'meta',
name : 'sponsor-tickets',
} )?.get( 'value' ) );
},
},

'per-speaker-volunteer' : {
'label' : ( networkStatus.isNextGenWordCamp ? 'per facilitator' : 'per speaker' ) + ' + volunteer',
'hasValue' : true,
Expand Down Expand Up @@ -504,6 +527,21 @@ window.wcb = window.wcb || { models: {}, input: [] };
},
},

'per-attendee-sponsor' : {
'label' : 'per attendee + sponsor',
'hasValue' : true,
'callback' : function( value ) {
return parseFloat( value ) * parseInt( wcb.table.collection.findWhere( {
type : 'meta',
name : 'attendees',
} ).get( 'value' ) )
+ parseInt( wcb.table.collection.findWhere( {
type : 'meta',
name : 'sponsor-tickets',
} ).get( 'value' ) );
},
},

'per-day' : {
'label' : 'per day',
'hasValue' : true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,23 +50,43 @@ class="nav-tab <?php if ( $view == 'working' ) { ?>nav-tab-active<?php } ?>">
<p style="max-width: 800px;"><?php esc_html_e( 'Welcome to your working budget. Feel free to play around with numbers here. They will not affect your approved budget.', 'wordcamporg' ); ?></p>
<?php endif; ?>

<div class="left">
<h2><?php esc_html_e( 'Event Data', 'wordcamporg' ); ?></h2>
<table class="wcb-budget-container">
<tbody>
<tr class="wcb-group-header">
<th style="width: 50%;"><?php esc_html_e( 'Name', 'wordcamporg' ); ?></th>
<th style="width: 50%;"><?php esc_html_e( 'Value', 'wordcamporg' ); ?></th>
</tr>
<tr class="wcb-meta-placeholder" style="display: none;">
<td colspan="2"></td>
</tr>
</tbody>
</table>
</div>
<div class="right">
<h2><?php esc_html_e( 'Summary', 'wordcamporg' ); ?></h2>
<div class="wcb-summary-placeholder"></div>
<div class="first-section">
<div>
<h2><?php esc_html_e( 'Event Data', 'wordcamporg' ); ?></h2>
<table class="wcb-budget-container">
<tbody>
<tr class="wcb-group-header">
<th style="width: 50%;"><?php esc_html_e( 'Name', 'wordcamporg' ); ?></th>
<th style="width: 50%;"><?php esc_html_e( 'Value', 'wordcamporg' ); ?></th>
</tr>
<tr class="wcb-meta-placeholder" style="display: none;">
<td colspan="2"></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
</tbody>
</table>
</div>
<div>
<h2><?php esc_html_e( 'Attendees', 'wordcamporg' ); ?></h2>
<table class="wcb-budget-container wcb-budget-attendees">
<tbody>
<tr class="wcb-group-header">
<th style="width: 50%;"><?php esc_html_e( 'Name', 'wordcamporg' ); ?></th>
<th style="width: 50%;"><?php esc_html_e( 'Value', 'wordcamporg' ); ?></th>
</tr>
<tr class="wcb-attendees-placeholder" style="display: none;">
<td colspan="2"></td>
</tr>
</tbody>
</table>
</div>
<div>
<h2><?php esc_html_e( 'Summary', 'wordcamporg' ); ?></h2>
<div class="wcb-summary-placeholder"></div>
</div>
</div>

<div class="clear"></div>
Expand Down Expand Up @@ -167,18 +187,6 @@ class="nav-tab <?php if ( $view == 'working' ) { ?>nav-tab-active<?php } ?>">
</td>
<td class="amount">{{data.per_person}}</td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td class="amount">
Expand Down

0 comments on commit fb68423

Please sign in to comment.