| 1 |
<?php |
| 2 |
|
| 3 |
namespace FluentForm\App\Modules\Report; |
| 4 |
|
| 5 |
if (!defined('ABSPATH')) { |
| 6 |
exit; // Exit if accessed directly. |
| 7 |
} |
| 8 |
|
| 9 |
use FluentForm\App\Helpers\Helper; |
| 10 |
use FluentForm\App\Modules\Registerer\TranslationString; |
| 11 |
use FluentForm\Framework\Helpers\ArrayHelper; |
| 12 |
use FluentForm\App\Modules\Payments\PaymentHelper; |
| 13 |
|
| 14 |
class ReportHandler |
| 15 |
{ |
| 16 |
protected $app; |
| 17 |
|
| 18 |
public function register($app) |
| 19 |
{ |
| 20 |
$this->app = $app; |
| 21 |
$app->addAction('fluentform/render_report', [$this, 'renderReport']); |
| 22 |
} |
| 23 |
|
| 24 |
public function renderReport() |
| 25 |
{ |
| 26 |
wp_enqueue_script('fluentform_reports'); |
| 27 |
wp_enqueue_style('fluentform_reports'); |
| 28 |
|
| 29 |
|
| 30 |
// Maybe load intl-tel-input flags |
| 31 |
if (Helper::hasPro() && defined('FLUENTFORMPRO_DIR_URL')) { |
| 32 |
$file = is_rtl() ? 'intlTelInput-rtl.min.css' : 'intlTelInput.min.css'; |
| 33 |
wp_enqueue_style( |
| 34 |
'intlTelInput', |
| 35 |
FLUENTFORMPRO_DIR_URL . 'public/libs/intl-tel-input/css/' . $file, |
| 36 |
[], |
| 37 |
'24.2.0' |
| 38 |
); |
| 39 |
} |
| 40 |
|
| 41 |
|
| 42 |
$hasPayment = false; |
| 43 |
$paymentSettings = get_option('__fluentform_payment_module_settings'); |
| 44 |
if ($paymentSettings && ArrayHelper::get($paymentSettings, 'status') === 'yes') { |
| 45 |
$hasPayment = true; |
| 46 |
} |
| 47 |
|
| 48 |
wp_localize_script('fluentform_reports', 'FluentFormApp', [ |
| 49 |
'has_payment' => $hasPayment, |
| 50 |
'has_pro' => Helper::hasPro(), |
| 51 |
'upgrade_url' => fluentform_upgrade_url(), |
| 52 |
'has_pdf' => defined('FLUENTFORM_PDF_VERSION'), |
| 53 |
'reports_i18n' => TranslationString::getReportsI18n(), |
| 54 |
'payment_statuses' => PaymentHelper::getPaymentStatuses(), |
| 55 |
'payment_methods' => apply_filters('fluentform/available_payment_methods', []) |
| 56 |
]); |
| 57 |
|
| 58 |
$this->app->view->render('admin.reports.index', [ |
| 59 |
'logo' => fluentformMix('img/fluentform-logo.svg'), |
| 60 |
]); |
| 61 |
} |
| 62 |
} |
| 63 |
|