Skip to content
Open
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
2 changes: 1 addition & 1 deletion classes/controllers/FrmDashboardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public static function get_dashboard_helper() {
return new FrmDashboardHelper(
array(
'counters' => array(
'counters' => self::view_args_counters( FrmForm::get_latest_form(), $counters_value ),
'counters' => self::view_args_counters( $counters_value['entries'] ? false : FrmForm::get_latest_form(), $counters_value ),
),
'license' => array(),
'get_free_templates' => array(),
Expand Down
27 changes: 23 additions & 4 deletions classes/helpers/FrmFormsListHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ class FrmFormsListHelper extends FrmListHelper {

public $total_items = 0;

/**
* Entry counts for forms on the current page.
*
* @var int[]
*/
private $entry_counts = array();

/**
* @param array $args
*/
Expand Down Expand Up @@ -115,9 +122,21 @@ public function prepare_items() {
}
}//end if

$this->items = FrmForm::getAll( $s_query, $orderby . ' ' . $order, $start . ',' . $per_page );
$total_items = FrmDb::get_count( 'frm_forms', $s_query );
$this->total_items = $total_items;
$this->items = FrmForm::getAll( $s_query, $orderby . ' ' . $order, $start . ',' . $per_page );
$total_items = FrmDb::get_count( 'frm_forms', $s_query );
$this->total_items = $total_items;
$this->entry_counts = array();

if ( $this->items && ! has_filter( 'frm_exclude_spam_entries' ) ) {
$form_ids = wp_list_pluck( $this->items, 'id' );
$where = FrmSpamEntriesHelper::exclude_spam( array( 'form_id' => $form_ids ), '' );
$counts = FrmDb::get_results( 'frm_items', $where, 'form_id, COUNT(*) AS total', array( 'group_by' => 'form_id' ) );
$this->entry_counts = array_fill_keys( $form_ids, 0 );

foreach ( $counts as $count ) {
$this->entry_counts[ $count->form_id ] = (int) $count->total;
}
}

$this->set_pagination_args(
array(
Expand Down Expand Up @@ -361,7 +380,7 @@ private function get_entries_column_value( $item ) {
);
}

$text = (int) FrmEntry::getRecordCount( $item->id );
$text = $this->entry_counts[ $item->id ] ?? (int) FrmEntry::getRecordCount( $item->id );
return current_user_can( 'frm_view_entries' ) ? '<a href="' . esc_url( admin_url( 'admin.php?page=formidable-entries&form=' . $item->id ) ) . '">' . $text . '</a>' : (string) $text; // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
}

Expand Down
2 changes: 1 addition & 1 deletion classes/views/dashboard/templates/counters.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<?php foreach ( $counter['items'] as $item ) : ?>
<b>
<?php echo esc_html( $item['counter_label']['symbol_left'] ); ?>
<span class="frm-counter" data-type="<?php echo esc_attr( $counter['type'] ); ?>" data-locale="<?php echo esc_attr( get_locale() ); ?>" data-counter="<?php echo (int) $item['counter']; ?>"><?php echo (int) $item['counter']; ?></span>
<span class="frm-counter" data-type="<?php echo esc_attr( $counter['type'] ); ?>" data-locale="<?php echo esc_attr( get_locale() ); ?>" data-counter="<?php echo (int) $item['counter']; ?>"><?php echo esc_html( number_format_i18n( (int) $item['counter'], 2 ) ); ?></span>
<?php echo esc_html( $item['counter_label']['symbol_right'] ); ?>
</b>
<?php endforeach; ?>
Expand Down
2 changes: 1 addition & 1 deletion js/formidable_dashboard.js

Large diffs are not rendered by default.

16 changes: 1 addition & 15 deletions js/src/dashboard.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
/**
* External dependencies
*/
import { frmAnimate } from 'core/utils';

import { frmTabsNavigator } from './components/tabs/class-tabs-navigator';
import { frmCounter } from './components/class-counter';

class frmDashboard {
constructor() {
this.options = {
Expand All @@ -17,15 +12,11 @@ class frmDashboard {
}
}
};
this.widgetsAnimate = new frmAnimate( document.querySelectorAll( '.frm-dashboard-widget' ), 'cascade' );
}

init() {
this.initInbox();
this.initCounters();
this.initCloseWelcomeBanner();

this.widgetsAnimate.cascadeFadeIn();
}

initInbox() {
Expand All @@ -38,11 +29,6 @@ class frmDashboard {
} );
}

initCounters() {
const counters = document.querySelectorAll( '.frm-counter' );
counters.forEach( counter => new frmCounter( counter ) );
}

initCloseWelcomeBanner() {
const closeButton = document.querySelector( '.frm-dashboard-banner-close' );
const dashboardBanner = document.querySelector( '.frm-dashboard-banner' );
Expand Down
9 changes: 7 additions & 2 deletions stripe/models/FrmTransLitePayment.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,18 @@ public function get_payments_stats( $from_date = null, $to_date = null ) {
$where['status'] = 'complete';
}

$payments = FrmDb::get_results( $this->table_name, $where, 'action_id,amount' );
$payments = FrmDb::get_results(
$this->table_name,
$where,
'action_id, SUM(amount) AS amount, COUNT(*) AS payment_count',
array( 'group_by' => 'action_id' )
);

if ( ! $payments ) {
return $data;
}

$data['count'] = count( $payments );
$data['count'] = (int) array_sum( wp_list_pluck( $payments, 'payment_count' ) );
$data['total'] = $this->get_payment_total_data( $payments );

return $data;
Expand Down