Skip to content

Commit

Permalink
small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
fmido88 committed Sep 1, 2024
1 parent d5d2599 commit c964da6
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 293 deletions.
10 changes: 9 additions & 1 deletion classes/hooks_callbacks.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ class hooks_callbacks {
* @return void
*/
public static function show_price(before_footer_html_generation $hook) {
if (during_initial_install()) {
return;
}

$showprice = (bool)get_config('enrol_wallet', 'showprice');
if ($showprice) {
$page = $hook->renderer->get_page();
Expand All @@ -50,7 +54,7 @@ public static function show_price(before_footer_html_generation $hook) {
*/
public static function low_balance_warning(before_standard_top_of_body_html_generation $hook) {
// Don't display notice for guests or logged out.
if (!isloggedin() || isguestuser()) {
if (!isloggedin() || isguestuser() || during_initial_install()) {
return;
}

Expand Down Expand Up @@ -78,6 +82,10 @@ public static function low_balance_warning(before_standard_top_of_body_html_gene
* @return void
*/
public static function add_offers(primary_extend $hook) {
if (during_initial_install()) {
return;
}

$enabled = (bool)get_config('enrol_wallet', 'offers_nav');
if (empty($enabled)) {
return;
Expand Down
9 changes: 6 additions & 3 deletions classes/output/wallet_balance.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,12 @@ public function export_for_template(renderer_base $output) {
$balancedetails[$id]->name = $category->get_nested_name(false);
}

$balancedetails[$id]->refundable = number_format($obj->refundable, 2) ?? 0;
$balancedetails[$id]->nonrefundable = number_format($obj->nonrefundable, 2) ?? 0;
$total = $obj->balance ?? $balancedetails[$id]->refundable + $balancedetails[$id]->nonrefundable;
$balancedetails[$id]->refundable = number_format($obj->refundable ?? 0, 2);
$balancedetails[$id]->nonrefundable = number_format($obj->nonrefundable ?? 0, 2);
$total = $obj->balance ?? (float)(($obj->refundable ?? 0) + ($obj->nonrefundable ?? 0));
$balancedetails[$id]->total = number_format($total, 2);
}

$balancedetails = !(empty($balancedetails)) ? array_values($balancedetails) : false;

$tempctx = new stdClass;
Expand All @@ -138,13 +139,15 @@ public function export_for_template(renderer_base $output) {
$tempctx->hasdetails = !empty($balancedetails);
$tempctx->catdetails = $balancedetails;
$tempctx->currency = $currency;

if (!AJAX_SCRIPT) {
$tempctx->transactions = $transactions;
$tempctx->transfer = !empty($transferenabled) ? $transfer : false;
$tempctx->referral = !empty($refenabled) ? $referral : false;
$tempctx->policy = !empty($policy) ? $policy : false;
$tempctx->walleturl = (new moodle_url('/enrol/wallet/wallet.php#linkbalance'))->out();
}

$tempctx->currentuser = $this->currentuser;
return $tempctx;
}
Expand Down
2 changes: 1 addition & 1 deletion classes/util/offers.php
Original file line number Diff line number Diff line change
Expand Up @@ -883,7 +883,7 @@ public static function validate($data) {

break;
case self::PROFILE_FIELD:
if (empty($offer->field)) {
if (empty($offer->cf) || empty($offer->sf)) {
$errors[self::fname($type, '', $i)] = get_string('offers_error_pfselect', 'enrol_wallet');
} else if (!in_array($offer->op, [self::PFOP_IS_EMPTY, self::PFOP_IS_NOT_EMPTY])) {
if (empty($offer->value)) {
Expand Down
175 changes: 0 additions & 175 deletions extra/action.php

This file was deleted.

113 changes: 0 additions & 113 deletions extra/generator.php

This file was deleted.

0 comments on commit c964da6

Please sign in to comment.