Commit c218a22a authored by Angel Matilla's avatar Angel Matilla
Browse files

added visualization of option table

parent 887928e8
......@@ -2,8 +2,8 @@
/**
* Plugin Name: GEN EU Registration Dashboard
* Description: This is a plugin to display information about the registration process of conferences and events.
* Version: 1.0.2
* Author: Rodrigo Espirito Santo Braga
* Version: 1.0.3
* Author: GEN Europe
*
* @package GEN_EU_Registration_Tracker
**/
......
......@@ -80,6 +80,7 @@ class GEN_EU_Caldera_Forms_Data_Collector {
$this->form_id = $form_id;
$this->error_list = new WP_Error();
$this->all_registrations = self::get_registrants_from_form( $form_id );
$this->all_options = self::get_options_from_wp();
}
/** Function that uses Caldera Forms API methods to fetch entries from a specific form.
......@@ -116,6 +117,26 @@ class GEN_EU_Caldera_Forms_Data_Collector {
return $all_registrations;
}
/** Function that gets the relevant options for the dashboard from the Wordpress options table
*
* @since 1.0.3
* @return array array with wp options.
*/
private function get_options_from_wp() {
$all_options = [];
$db_accommodation = get_option( 'gen_eu_accommodation_bookings' );
$db_coupons = get_option( 'gen_eu_coupons' );
$db_tier_price = get_option( 'gen_eu_tier_price' );
$db_attendees = get_option( 'gen_eu_number_of_attendees' );
$db_youth_discount = get_option( 'gen_eu_youth_discount_available' );
$db_group_discount = get_option( 'gen_eu_group_discount_available' );
$db_aspiring_members = get_option( 'gen_eu_aspiring_members' );
$db_full_members = get_option( 'gen_eu_full_members' );
$db_network_members = get_option( 'gen_eu_network_members' );
$all_options[] = $db_accommodation;
return $all_options;
}
/** Function that iterates through the data of a registration entry and return arrays of objects from GEN_EU_Registrant class.
*
* @param array $registration_array array of data from a registration.
......@@ -503,4 +524,12 @@ class GEN_EU_Caldera_Forms_Data_Collector {
public function get_all_registrations() {
return $this->all_registrations;
}
/** Retrieves all wp options relevant for the dashboard.
*
* @since 1.0.3
* @return array array with wp options.
*/
public function get_all_options() {
return $this->all_options;
}
}
......@@ -161,6 +161,14 @@ class GEN_EU_Dashboard_Loader {
* @var float $total_donations_income Total donations income.
*/
protected $total_donations_income;
/**
* List of wp options related to form.
*
* @since 1.0.3
* @access private
* @var array $all_options List of wp options related to form.
*/
private $all_options = [];
/**
* Retrieves the class instance.
*
......@@ -186,6 +194,7 @@ class GEN_EU_Dashboard_Loader {
$this->total_donations_income = 0;
$this->total_accommodation_income = 0;
$all_registrations = $data_source->get_all_registrations();
$this->all_options = $data_source->get_all_options();
foreach ( $data_source->get_diet_types() as $type_name ) {
$this->number_of_registrants_by_diet_type_list[ $type_name ] = 0;
}
......
......@@ -31,6 +31,7 @@ class GEN_EU_Dashboard_Viewer {
self::display_region_info_card( $dashboard );
self::display_country_info_card( $dashboard );
self::display_delegates_info_card( $dashboard );
self::display_wp_options_card( $dashboard );
if ( ! empty( $dashboard->get_error_list()->get_error_code() ) ) {
GEN_EU_Utility::print_errors( $dashboard->get_error_list() );
......@@ -275,8 +276,8 @@ class GEN_EU_Dashboard_Viewer {
<div class="gen-container">
<hr>
<?php
foreach ( $dashboard->get_number_of_registrants_by_trasnportation_list() as $transportation => $sum ) {
echo '<strong>' . esc_html( $transportation ) . ' </strong><span class="gen-value">' . esc_html( $sum ) . '</span><hr>';
foreach ( $dashboard->get_number_of_registrants_by_trasnportation_list() as $options => $value ) {
echo '<strong>' . esc_html( $transportation ) . ' </strong><span class="gen-value">' . esc_html( $value ) . '</span><hr>';
}
?>
</div>
......@@ -331,4 +332,31 @@ class GEN_EU_Dashboard_Viewer {
</div>
<?php
}
/** Function that displays a card containing the wp options associated to the table
*
* @param GEN_EU_Dashboard_Loader $dashboard Object of type GEN_EU_Dashboard_Loader containing all the information from the registration.
* @since 1.0.3
*/
private static function display_wp_options_card( $dashboard ) {
if ( ! $dashboard instanceof GEN_EU_Dashboard_Loader ) {
GEN_EU_Utility::print_errors( new WP_Error( 'no_valid_dashboard_instance', 'Dashboard Viewer: WordPress Options Table card has not received a valid dashboard instance.' ) );
return;
}
?>
<div class="info-card">
<header class="gen-container gen-blue">
<h1>WordPress Options Table</h1>
</header>
<div class="gen-container">
<hr>
<?php
foreach ( $dashboard->get_all_options() as $transportation => $sum ) {
echo '<strong>' . esc_html( $transportation ) . ' </strong><span class="gen-value">' . esc_html( $sum ) . '</span><hr>';
}
?>
</div>
</div>
<?php
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment