parent
94e347693c
commit
c033bf6fa9
@ -0,0 +1,75 @@ |
||||
<?php |
||||
/** |
||||
* User Panel |
||||
* @package chamilo.plugin.buycourses |
||||
*/ |
||||
/** |
||||
* Initialization |
||||
*/ |
||||
|
||||
$cidReset = true; |
||||
|
||||
require_once '../../../main/inc/global.inc.php'; |
||||
$plugin = BuyCoursesPlugin::create(); |
||||
$includeServices = $plugin->get('include_services') === 'true'; |
||||
$includeSessions = $plugin->get('include_sessions') === 'true'; |
||||
$servicesOnly = $plugin->get('show_services_only') === 'true'; |
||||
|
||||
$userInfo = api_get_user_info(); |
||||
|
||||
if (!$userInfo) { |
||||
api_not_allowed(true); |
||||
} |
||||
|
||||
$em = Database::getManager(); |
||||
$paymentTypes = $plugin->getPaymentTypes(); |
||||
$serviceTypes = $plugin->getServiceTypes(); |
||||
|
||||
$serviceSaleStatuses['status_cancelled'] = BuyCoursesPlugin::SERVICE_STATUS_CANCELLED; |
||||
$serviceSaleStatuses['status_pending'] = BuyCoursesPlugin::SERVICE_STATUS_PENDING; |
||||
$serviceSaleStatuses['status_completed'] = BuyCoursesPlugin::SERVICE_STATUS_COMPLETED; |
||||
|
||||
$serviceSales = $plugin->getServiceSale(null, $userInfo['user_id']); |
||||
$saleList = []; |
||||
|
||||
foreach ($serviceSales as $sale) { |
||||
|
||||
$saleList[] = [ |
||||
'id' => $sale['id'], |
||||
'name' => $sale['service']['name'], |
||||
'service_type' => $serviceTypes[$sale['service']['applies_to']], |
||||
'applies_to' => $sale['service']['applies_to'], |
||||
'reference' => $sale['reference'], |
||||
'date' => api_format_date(api_get_local_time($sale['buy_date']), DATE_TIME_FORMAT_LONG_24H), |
||||
'date_end' => api_format_date(api_get_local_time($sale['date_end']), DATE_TIME_FORMAT_LONG_24H), |
||||
'currency' => $sale['currency'], |
||||
'price' => $sale['price'], |
||||
'status' => $sale['status'] |
||||
]; |
||||
} |
||||
|
||||
$toolbar = Display::toolbarButton( |
||||
$plugin->get_lang('CourseListOnSale'), |
||||
'course_catalog.php', |
||||
'search-plus', |
||||
'primary', |
||||
['title' => $plugin->get_lang('CourseListOnSale')] |
||||
); |
||||
|
||||
$templateName = $plugin->get_lang('TabsDashboard'); |
||||
$tpl = new Template($templateName); |
||||
$tpl->assign('showing_courses', true); |
||||
$tpl->assign('services_are_included', $includeServices); |
||||
$tpl->assign('sessions_are_included', $includeSessions); |
||||
$tpl->assign('service_sale_statuses', $serviceSaleStatuses); |
||||
$tpl->assign('sale_list', $saleList); |
||||
if ($servicesOnly) { |
||||
$tpl->assign('show_services_only', true); |
||||
} |
||||
|
||||
$content = $tpl->fetch('buycourses/view/service_panel.tpl'); |
||||
|
||||
$tpl->assign('actions', $toolbar); |
||||
$tpl->assign('header', $templateName); |
||||
$tpl->assign('content', $content); |
||||
$tpl->display_one_col_template(); |
@ -0,0 +1,94 @@ |
||||
<link rel="stylesheet" type="text/css" href="../resources/css/style.css"/> |
||||
<script type="text/javascript" src="../resources/js/modals.js"></script> |
||||
|
||||
|
||||
<div id="buy-courses-tabs"> |
||||
|
||||
<ul class="nav nav-tabs buy-courses-tabs" role="tablist"> |
||||
<li id="buy-courses-tab" class="" role="presentation"> |
||||
<a href="course_panel.php" aria-controls="buy-courses" role="tab">{{ 'MyCourses'| get_lang }}</a> |
||||
</li> |
||||
{% if sessions_are_included %} |
||||
<li id="buy-sessions-tab" class="" role="presentation"> |
||||
<a href="session_panel.php" aria-controls="buy-sessions" role="tab">{{ 'MySessions'| get_lang }}</a> |
||||
</li> |
||||
{% endif %} |
||||
{% if services_are_included %} |
||||
<li id="buy-services-tab" class="active" role="presentation"> |
||||
<a href="service_panel.php" aria-controls="buy-services" role="tab">{{ 'MyServices'| get_plugin_lang('BuyCoursesPlugin') }}</a> |
||||
</li> |
||||
{% endif %} |
||||
<li id="buy-courses-tab" class="" role="presentation"> |
||||
<a href="payout_panel.php" aria-controls="buy-courses" role="tab">{{ 'MyPayouts'| get_plugin_lang('BuyCoursesPlugin') }}</a> |
||||
</li> |
||||
</ul> |
||||
|
||||
|
||||
<table class="table table-striped table-hover"> |
||||
<thead> |
||||
<tr> |
||||
<th>{{ 'Service'| get_plugin_lang('BuyCoursesPlugin') }}</th> |
||||
<th class="text-center">{{ 'AppliesTo'|get_plugin_lang('BuyCoursesPlugin') }}</th> |
||||
<th class="text-center">{{ 'Price'|get_plugin_lang('BuyCoursesPlugin') }}</th> |
||||
<th class="text-center">{{ 'OrderDate'|get_plugin_lang('BuyCoursesPlugin') }}</th> |
||||
<th class="text-center">{{ 'OrderReference'|get_plugin_lang('BuyCoursesPlugin') }}</th> |
||||
<th class="text-center">{{ 'ServiceSaleInfo'|get_plugin_lang('BuyCoursesPlugin') }}</th> |
||||
</tr> |
||||
</thead> |
||||
<tbody> |
||||
{% for sale in sale_list %} |
||||
<tr class="{{ sale.status == service_sale_statuses.status_cancelled ? 'buy-courses-cross-out' : '' }}"> |
||||
<td>{{ sale.name }}</td> |
||||
<td class="text-center">{{ sale.service_type }}</td> |
||||
<td class="text-center">{{ sale.currency ~ ' ' ~ sale.price }}</td> |
||||
<td class="text-center">{{ sale.date }}</td> |
||||
<td class="text-center">{{ sale.reference }}</td> |
||||
<td class="text-center"> |
||||
<a id="service_sale_info" tag="{{ sale.id }}" name="s_{{ sale.id }}" class="btn btn-info btn-sm">{{ 'Info' | get_lang }}</a> |
||||
</td> |
||||
</td> |
||||
</tr> |
||||
{% endfor %} |
||||
</tbody> |
||||
</table> |
||||
</div> |
||||
<script> |
||||
$(document).on('ready', function () { |
||||
$("td a").click(function() { |
||||
var id = $(this).attr('tag'); |
||||
var action = $(this).attr('id'); |
||||
$.ajax({ |
||||
data: 'id='+id, |
||||
url: '{{ _p.web_plugin }}buycourses/src/buycourses.ajax.php?a='+action, |
||||
type: 'POST', |
||||
beforeSend: function() { |
||||
if (action == 'renewable_info') { |
||||
$('a[name=r_'+id+']').html('<em class="fa fa-spinner fa-pulse"></em> {{ 'Loading' | get_lang }}'); |
||||
} else if (action == 'service_sale_info') { |
||||
$('a[name=s_'+id+']').html('<em class="fa fa-spinner fa-pulse"></em> {{ 'Loading' | get_lang }}'); |
||||
} |
||||
}, |
||||
success: function(response) { |
||||
$('a[name=r_'+id+']').html('{{ 'Info' | get_lang }}'); |
||||
$('a[name=s_'+id+']').html('{{ 'Info' | get_lang }}'); |
||||
var title = ""; |
||||
if (action == "renewable_info") { |
||||
title = "{{ 'RecurringPaymentProfilePaypalInformation' | get_plugin_lang('BuyCoursesPlugin') }}"; |
||||
} else if (action == 'service_sale_info') { |
||||
title = "{{ 'ServiceSaleInfo' | get_plugin_lang('BuyCoursesPlugin') }}"; |
||||
} |
||||
bootbox.dialog({ |
||||
message: response, |
||||
title: title, |
||||
buttons: { |
||||
main: { |
||||
label: "{{ 'Close' | get_lang }}", |
||||
className: "btn-default" |
||||
} |
||||
} |
||||
}); |
||||
} |
||||
}) |
||||
}); |
||||
}); |
||||
</script> |
Loading…
Reference in new issue