50 lines
1.3 KiB
HTML
Raw Normal View History

2019-05-30 16:35:15 +05:30
{% macro hero(title, description, has_access) %}
2019-05-21 12:05:19 +05:30
<div class='container pb-5'>
2019-05-30 16:35:15 +05:30
<h1>{{ title }} </h1>
2019-05-21 12:05:19 +05:30
<p class='lead' style="max-width: 100%;">{{ description }}</p>
<p class="mt-4">
{% if frappe.session.user == 'Guest' %}
2019-05-29 18:38:09 +05:30
<a id="signup" class="btn btn-primary btn-lg" href="/login#signup">Sign Up</a>
2019-05-30 16:35:15 +05:30
{% elif not has_access %}
<button id="enroll" class="btn btn-primary btn-lg" onclick="enroll()" disabled>Enroll</button>
{% endif %}
2019-05-21 12:05:19 +05:30
</p>
</div>
{% block script %}
<script type="text/javascript">
2019-05-30 16:35:15 +05:30
frappe.ready(() => {
btn = document.getElementById('enroll');
if (btn) btn.disabled = false;
})
2019-05-29 18:38:09 +05:30
function enroll() {
2019-05-30 16:35:15 +05:30
let params = frappe.utils.get_query_params()
2019-05-30 18:04:36 +05:30
2019-05-30 16:35:15 +05:30
let btn = document.getElementById('enroll');
btn.disbaled = true;
btn.innerText = 'Enrolling...'
let opts = {
method: 'erpnext.education.utils.enroll_in_program',
args: {
program_name: params.program
}
}
frappe.call(opts).then(res => {
let success_dialog = new frappe.ui.Dialog({
title: __('Success'),
secondary_action: function() {
window.location.reload()
}
})
success_dialog.set_message('You have successfully enrolled for the program ');
success_dialog.$message.show()
success_dialog.show();
btn.disbaled = false;
})
2019-05-29 18:38:09 +05:30
}
2019-05-21 12:05:19 +05:30
</script>
{% endblock %}
{% endmacro %}