Skip to content

Commit

Permalink
bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
fmido88 authored Feb 16, 2024
1 parent bd51c00 commit 29be817
Show file tree
Hide file tree
Showing 9 changed files with 204 additions and 60 deletions.
3 changes: 1 addition & 2 deletions extra/charger.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,7 @@
$msg = get_string('confirm_credit', 'enrol_wallet', $a);
list($extra, $condition) = enrol_wallet\util\discount_rules::get_the_rest($data['value'], $data['category']);
if (!empty($extra)) {
$a = ['extra' => $extra, 'condition' => $condition];
$msg .= '<br>'.get_string('confirm_additional_credit', 'enrol_wallet', $a);
$msg .= '<br>'.get_string('confirm_additional_credit', 'enrol_wallet', $extra);
}
break;
default:
Expand Down
2 changes: 1 addition & 1 deletion extra/offers.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@

if (!empty($config->referral_enabled) && (float)$config->referral_amount > 0) {
$out .= $OUTPUT->heading(get_string('referral_program', 'enrol_wallet'));
$url = new moodle_url('/enrol/wallet/referral.php');
$url = new moodle_url('/enrol/wallet/extra/referral.php');
$text = get_string('clickhere');
$link = html_writer::link($url, $text);
$out .= $OUTPUT->box(get_string('referral_site_desc', 'enrol_wallet') . $link);
Expand Down
27 changes: 27 additions & 0 deletions lang/ar/enrol_wallet.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,19 @@

$string['cachedef_balance'] = 'تخزين بيانات عن رصيد المستخدم';
$string['cachedef_coupon'] = 'تخزين بيانات عن الكوبونات';
$string['cachedef_offers'] = 'Offers cache data';
$string['cannotdeductbalance'] = 'لا يمكن خصم الرصيد بسبب حدوث خطأ. الرجاء المحاولة مرة أخرى وإذا كانت المشكلة لا تزال موجودة، فاتصل بدعم الموقع.';
$string['canntenrol'] = 'التسجيل معطل أو غير نشط';
$string['canntenrolearly'] = 'لا يمكنك التسجيل بعد؛ يبدأ التسجيل في {$a}.';
$string['canntenrollate'] = 'لا يمكنك التسجيل بعد الآن، منذ انتهاء التسجيل في {$a}.';
$string['cashback'] = 'كاشباك';
$string['cashbackdesc'] = 'تمت الإضافة عن طريق الاسترداد النقدي بسبب التسجيل في {$a}';
$string['cashbackenable'] = 'تمكين الاسترداد النقدي';
$string['cashbackenable_desc'] = 'عندما يتم تمكين هذا، سيحصل الطالب على نسبة مئوية من مبلغ الاسترداد النقدي في كل مرة يستخدم فيها المحفظة لشراء مقرر تدريبية.';
$string['cashbackpercent'] = 'النسبة المئوية لمبلغ الاسترداد النقدي';
$string['cashbackpercent_help'] = 'النسبة المئوية للمبلغ المسترد للمحفظة من المبلغ المدفوع بواسطة رصيد المحفظة.';
$string['cashback_desc'] = 'سوف تحصل على {$a}% كاشباك لكل مرة تشتري محاضرة بإستخدام المحفظة.';
$string['catbalance'] = 'رصيد الفئات';
$string['categorycoupon'] = 'كوبون الفئة';
$string['categorycoupondisabled'] = 'كوبونات الفئات غير مفعلة.';
$string['category_options'] = 'الفئة';
Expand Down Expand Up @@ -234,6 +238,7 @@
$string['coursesrestriction_help'] = 'فقط المستخدمين المسجلين في أكثر من أو يساوي العدد المطلوب من المقررات المحددة يمكنهم شراء هذه المقرر.';
$string['coursesrestriction_num'] = 'عدد المقررات المطلوبة';
$string['coursesrestriction_num_help'] = 'اختر الحد الأدنى من المقررات المطلوبة التي يجب على المستخدم تسجيلها لشراء هذه المقرر باستخدام هذا المثال.';
$string['courseswithdiscounts'] = 'محاضرات بها عروض خصم';
$string['courses_options'] = 'المقررات';
$string['courses_options_help'] = 'اختر المقررات لتسجيل المستخدم مباشرة باستخدام هذه الكوبونات.';
$string['createdfrom'] = 'تم الإنشاء بعد';
Expand Down Expand Up @@ -272,7 +277,9 @@
$string['defaultrole_desc'] = 'اختر الدور الذي يجب تعيينه للمستخدمين أثناء التسجيل';
$string['deleteselectedusers'] = 'حذف تسجيلات المستخدم المحدد';
$string['digits'] = 'أرقام (أرقام)';
$string['discount'] = 'خصم';
$string['discountcoupondisabled'] = 'كوبونات الخصم معطلة في هذا الموقع.';
$string['discounts'] = 'خصومات';
$string['discountscopouns'] = 'الخصومات والكوبونات';
$string['discountscopouns_desc'] = 'اختر ما إذا كنت تريد تطبيق نسبة الخصومات على المستخدمين باستخدام حقل ملف تعريف مخصص. <br>
وأيضًا، تطبيق كوبونات لهذا البرنامج المساعد.';
Expand Down Expand Up @@ -331,6 +338,7 @@
$string['filter_transaction'] = 'معاملات التصفية';
$string['fixedcoupondisabled'] = 'الكوبونات ذات القيمة الثابتة معطلة في هذا الموقع.';
$string['fixedvaluecoupon'] = 'كوبون ذات قيمة ثابتة';
$string['freecourses'] = 'مقررات مجانية';


$string['giftdesc'] = 'مستخدم جديد بالمعرف {$a->userid} في {$a->time} حصل على هدية بقيمة {$a->amount} في محفظته.';
Expand Down Expand Up @@ -410,6 +418,19 @@
$string['not_set'] = 'غير محدد';


$string['offers'] = 'عروض';
$string['offers_ce_desc'] = '{$a->discount}% خصم إنت كنت بالفعل مشترك في {$a->condition} من هذه المقررات:<br> {$a->courses}';
$string['offers_course_enrol_based'] = 'خصم مبني على الإشتراك في مقررات أخرى';
$string['offers_nc_desc'] = '{$a->discount}% خصم إن كنت بالفعل مشترك في عدد {$a->number} مقررات لنفس الفئة {$a->catname}';
$string['offers_pfop_contains'] = 'يحتوي على';
$string['offers_pfop_doesnotcontain'] = 'لا يحتوي على';
$string['offers_pfop_endswith'] = 'يتنهي بـ';
$string['offers_pfop_isempty'] = 'فارغ';
$string['offers_pfop_isequalto'] = 'يساوي';
$string['offers_pfop_isnotempty'] = 'غير فارغ';
$string['offers_pfop_startswith'] = 'يبدأ بـ';
$string['offers_pf_desc'] = '{$a->discount}% خصم إن كانت خانة الملف الشخصي {$a->field} {$a->op} "{$a->value}"';
$string['offers_time_desc'] = '{$a->discount}% خصم إن إشتركت في الكورس في الفترة من {$a->from} إلى {$a->to}';
$string['othercourserestriction'] = 'غير قادر على تسجيل نفسك في هذه المقرر إلا إذا كنت مسجلاً في هذه المقررات {$a}';


Expand Down Expand Up @@ -506,7 +527,13 @@
$string['topup'] = 'اشحن رصيدك';
$string['topupafterdiscount'] = 'الدفع الفعلي';
$string['topupafterdiscount_help'] = 'المبلغ بعد الخصم.';
$string['topupbycoupon'] = 'بإستخدام الكوبونات (الأكواد)';
$string['topupbypayment'] = 'دفع مباشر';
$string['topupbytellerman'] = 'يدويا عن طريقنا';
$string['topupbyvc'] = 'عن طريق التحويل لمحافظ الموبايلات أو إنسناباي';
$string['topupcoupon_desc'] = 'بواسطة رمز الكوبون {$a}';
$string['topupoffers'] = 'عروض شحن المحفظة';
$string['topupoffers_desc'] = 'إن شحنت المحفظة بأحد القيم المتاحة أو أكثر منها, فإنك شوف تحصل على الخصم المتاح وستدفع فقط قيمة أقل من المفترض.';
$string['topuppayment_desc'] = 'تعبئة المحفظة عن طريق دفع {$a} باستخدام بوابة الدفع.';
$string['topupvalue'] = 'قيمة الشحن';
$string['topupvalue_help'] = 'قيمة تعبئة محفظتك باستخدام طرق الدفع';
Expand Down
7 changes: 6 additions & 1 deletion lang/en/enrol_wallet.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@
$string['confirmpayment'] = 'Confirm payment of {$a->value} {$a->currency}. Note that: press yes means that you have agreed to refund policy.<br> {$a->policy}';
$string['confirmpayment_discounted'] = 'Confirm payment of <del>{$a->before} {$a->currency}</del> {$a->value} {$a->currency}. Note that: press yes means that you have agreed to refund policy.<br> {$a->policy}';
$string['confirm_additional_credit'] = '<strong> With addition to {$a} due to conditional discount.</strong>';
$string['confirm_credit'] = 'You are about to add an amount of {$a->amount} to the user {$a->name} <strong>{$a->category} wallet</strong> who already got a balance of {$a->balance} valid it.';
$string['confirm_credit'] = 'You are about to add an amount of {$a->amount} to the user {$a->name} <strong>{$a->category} wallet</strong> who already got a balance of {$a->balance} valid in it.';
$string['confirm_debit'] = 'You are about to deduct an amount of {$a->amount} from the user {$a->name} in the <strong>{$a->category} balance</strong> whose current balance is {$a->balance} valid to be used in {$a->category}. The balance after transaction should be {$a->after}';
$string['confirm_enrol_confirm'] = 'You are about to get enrolled is the course <strong>{$a->course}</strong>. <br>
This require a <strong>{$a->cost} {$a->currency}</strong> to be deducted from you balance. <br>
Expand Down Expand Up @@ -382,6 +382,7 @@


$string['mainbalance'] = 'Main balance: ';
$string['manualrefundboxlabel'] = 'Check the following box to display the top up options.';
$string['maxenrolled'] = 'Max enrolled users';
$string['maxenrolledreached'] = 'Maximum number of users allowed to enrol was already reached.';
$string['maxenrolled_help'] = 'Specifies the maximum number of users that can enrol. 0 means no limit.';
Expand Down Expand Up @@ -607,6 +608,10 @@
$string['topup'] = 'topup';
$string['topupafterdiscount'] = 'Actual payment';
$string['topupafterdiscount_help'] = 'The amount after discount.';
$string['topupbycoupon'] = 'Using Coupons';
$string['topupbypayment'] = 'Using Payment';
$string['topupbytellerman'] = 'Manually from ourside';
$string['topupbyvc'] = 'Using transfer to mobile wallet or instapay';
$string['topupcoupon_desc'] = 'by coupon code {$a}';
$string['topupoffers'] = 'Wallet Topping Up offers';
$string['topupoffers_desc'] = 'By topping up your wallet by one or greater than the given values you will be discounted by the specified amount and only have to pay less than this amount by this percentage value.';
Expand Down
67 changes: 31 additions & 36 deletions locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,8 @@ function enrol_wallet_display_topup_options() {
// Display options to charge with coupons or other payment methods.
$topupurl = new moodle_url('/enrol/wallet/extra/topup.php');
$topupform = new \enrol_wallet\form\topup_form($topupurl, $data);
$render .= $topupform->render();
$rules = discount_rules::get_the_discount_line(-1);
$render .= enrol_wallet_topup_option($rules . $topupform->render(), get_string('topupbypayment', 'enrol_wallet'));
}

// Check if fixed coupons enabled.
Expand All @@ -511,49 +512,40 @@ function enrol_wallet_display_topup_options() {
enrol_wallet_process_coupon_data($submitteddata);
}

$render .= $couponform->render();
$render .= enrol_wallet_topup_option($couponform->render(), get_string('topupbycoupon', 'enrol_wallet'));
}

// If plugin block_vc exist, add credit options by it.
if (file_exists("$CFG->dirroot/blocks/vc/classes/form/vc_credit_form.php")
&& get_config('block_vc', 'enablecredit')) {
&& (bool)get_config('block_vc', 'enablecredit')) {

require_once("$CFG->dirroot/blocks/vc/classes/form/vc_credit_form.php");
$vcform = new \block_vc\form\vc_credit_form($CFG->wwwroot.'/blocks/vc/credit.php');

$render .= $OUTPUT->box($vcform->render());

// This code make the container collapsed at the load of the page, where setExpanded not working.
$jscode = "
var vcContainer = document.getElementById('id_vccreditcontainer');
vcContainer.setAttribute('class', 'fcontainer collapseable collapse');
";
$PAGE->requires->js_init_code($jscode, true);
$render .= enrol_wallet_topup_option($vcform->render(), get_string('topupbyvc', 'enrol_wallet'));
}

// Display teller men (user with capabilities to credit and choosen in the settings to be displayed).
$tellermen = get_config('enrol_wallet', 'tellermen');
if (!empty($tellermen)) {
require_once($CFG->dirroot.'/user/lib.php');
$chargerids = explode(',', $tellermen);
$render .= $OUTPUT->box_start();
$render .= $OUTPUT->heading(get_string('tellermen_display_guide', 'enrol_wallet'), 6);
$render .= html_writer::start_tag('ul');
$tm = $OUTPUT->box_start();
$tm .= $OUTPUT->heading(get_string('tellermen_display_guide', 'enrol_wallet'), 6);
$tm .= html_writer::start_tag('ul');
foreach ($chargerids as $tellerid) {
$teller = core_user::get_user($tellerid);
$tellername = fullname($teller);
if (user_can_view_profile($teller)) {
$tellername = html_writer::link(new moodle_url('/user/view.php', ['id' => $tellerid]), $tellername);
}
$render .= html_writer::tag('li', $tellername);
$tm .= html_writer::tag('li', $tellername);
}
$render .= html_writer::end_tag('ul');
$render .= $OUTPUT->box_end();
$tm .= html_writer::end_tag('ul');
$tm .= $OUTPUT->box_end();
$render .= enrol_wallet_topup_option($tm, get_string('topupbytellerman', 'enrol_wallet'));
}

if (!empty($render)) {
$render = discount_rules::get_the_discount_line(-1) . $render;
}
// Display the manual refund policy.
$policy = get_config('enrol_wallet', 'refundpolicy');
if (!empty($policy) && !empty($render)) {
Expand All @@ -567,6 +559,7 @@ function enrol_wallet_display_topup_options() {
$data = new stdClass;
$data->policy = $policy;
$data->id = $id;
$data->topup = true;
$warn .= $OUTPUT->render_from_template('enrol_wallet/manualpolicy', $data);

// Agree checkbox, the whole topping up options hidden until the user check the box.
Expand All @@ -580,29 +573,31 @@ function enrol_wallet_display_topup_options() {
$box = $OUTPUT->box_start('enrol_wallet_topup_options generalbox', 'enrol_wallet_topup_box_'.$id, $attr);
$render = $warn . $box . $render;
$render .= $OUTPUT->box_end();

// JS code to Hide/Show topping up options.
$jscode = "
var walletPolicyAgreed = document.getElementById('wallet_topup_policy_confirm_$id');
walletPolicyAgreed.addEventListener('change', function() {
var topUpBox = document.getElementById('enrol_wallet_topup_box_$id');
if (walletPolicyAgreed.checked == true) {
topUpBox.style.display = 'block';
} else {
topUpBox.style.display = 'none';
}
})
";
$PAGE->requires->js_init_code($jscode);
}

if (!empty($render)) {
return $OUTPUT->box($render);
return $OUTPUT->box($render, 'generalbox enrol_wallet_topup');
} else {
return '';
}
}

/**
* Add the top up option to accordion element.
* @param string $content the content of accordion
* @param string $label
* @return string
*/
function enrol_wallet_topup_option($content, $label) {
static $i = 0;
$chked = empty($i) ? 1 : null;
$out = html_writer::start_div('accordion');
$radio = html_writer::tag('input', '', ['type' => 'radio', 'name' => 'radio', 'id' => 'topup_radio_'.$i, 'checked' => $chked]);
$out .= html_writer::label("$label".$radio, 'topup_radio_'.$i, true, ['class' => 'accordion__title']);
$out .= html_writer::div($content, 'accordion__text');
$out .= html_writer::end_div();
$i++;
return $out;
}
/**
* Check the payment account id if it is valid or not.
*
Expand Down
71 changes: 70 additions & 1 deletion styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
flex-wrap: nowrap;
align-items: flex-end;
height: 12px;
margin-top: 60px;
margin-top: 75px;
background-color: white;
border-color: black;
border-style: outset;
Expand All @@ -115,4 +115,73 @@
.enrol-wallet-discounts-container .discount-line .rule-container {
position: absolute;
border-left: 1px solid #000;
font-size: 1em;
}
.enrol-wallet-discounts-container .discount-line .rule-container .discount-percent {
font-size: 1.1em;
}
.enrol-wallet-discounts-container .discount-cat-container {
margin-top: 10px;
}

@media screen and (max-width: 600px) {
.enrol-wallet-discounts-container .discount-line .rule-container .discount-percent {
font-size: 1em;
}
.enrol-wallet-discounts-container .discount-line .rule-container {
max-width: min-content;
font-size: 0.8em;
}
}

.enrol_wallet_topup .accordion .accordion__title {
display: block;
font-size: 1.1rem;
text-transform: uppercase;
font-weight: 700;
border-bottom: 1px solid #0002;
padding: 20px 10px;
margin-top: 10px;
transition: all 0.25s ease;
cursor: pointer;
background-color: #96cbcb;
border-radius: 30px 30px;
}

.enrol_wallet_topup .accordion .accordion__title input {
appearance: none;
}

.enrol_wallet_topup .accordion .accordion__title:after {
/* font-family: "Font Awesome 5 Free"; */
text-transform: unset;
transition: all 0.25s ease;
font-weight: 900;
content: '\2B9E';
float: right;
margin-right: 10px;
}

.enrol_wallet_topup .accordion .accordion__title:has(input:checked) {
color: rgb(255 219 166);
background-color: #005145;
border-radius: 30px 30px 0 0;
}

.enrol_wallet_topup .accordion .accordion__title:has(input:checked):after {
/* font-family: "Font Awesome 5 Free"; */
font-weight: 900;
content: '\2B9F';
float: right;
margin-right: 10px;
}

.enrol_wallet_topup .accordion .accordion__text {
overflow: hidden;
max-height: 0;
transition: all .5s ease-in-out;
}

.enrol_wallet_topup .accordion .accordion__title:has(input:checked) + .accordion__text {
max-height: 1080px;
}
32 changes: 17 additions & 15 deletions templates/discount-line.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,24 @@
}}
<div class="enrol-wallet-discounts-container">
{{# data}}
<div class="discount-line" data-catid="{{catid}}">
{{{heading}}}
{{# discounts}}
<div class="rule-container" style="left:{{percent}}%">
<h5>{{discount}}</h5>
<p class="condition">
{{condition}}
</p>
<div class="discount-cat-container" data-catid="{{catid}}">
{{{heading}}}
<div class="discount-line">
{{# discounts}}
<div class="rule-container" style="left:{{percent}}%;">
<h5 class="discount-percent">{{discount}}</h5>
<p class="condition">
{{condition}}
</p>
</div>
<span style="left:{{percent}}%;{{!
}}position:absolute;{{!
}}width:calc(100% - {{percent}}%);{{!
}}height: 100%;{{!
}}z-index:{{order}};{{!
}}background-color: rgb({{color}} {{color}} 255);"></span>
{{/ discounts}}
</div>
<span style="left:{{percent}}%;{{!
}}position:absolute;{{!
}}width:calc(100% - {{percent}}%);{{!
}}height: 100%;{{!
}}z-index:{{order}};{{!
}}background-color: rgb({{color}} {{color}} 255);"></span>
{{/ discounts}}
</div>
{{/ data}}
</div>
Loading

0 comments on commit 29be817

Please sign in to comment.