Plugin: BuyCourses: Add discount coupons feature by @nosolored
parent
d8f7ea313c
commit
4d8435ab18
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 5.0 KiB |
|
After Width: | Height: | Size: 6.3 KiB |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,204 @@ |
||||
<?php |
||||
/* For license terms, see /license.txt */ |
||||
|
||||
/** |
||||
* Configuration script for the Buy Courses plugin. |
||||
* |
||||
* @package chamilo.plugin.buycourses |
||||
*/ |
||||
require_once '../config.php'; |
||||
|
||||
api_protect_admin_script(); |
||||
|
||||
$couponId = $_REQUEST['id']; |
||||
|
||||
if (!isset($couponId)) { |
||||
api_not_allowed(); |
||||
} |
||||
|
||||
$plugin = BuyCoursesPlugin::create(); |
||||
|
||||
$coupon = $plugin->getCouponInfo($couponId); |
||||
|
||||
if (!isset($coupon)) { |
||||
api_not_allowed(); |
||||
} |
||||
|
||||
$couponDateRangeFrom = $coupon['valid_start']; |
||||
$couponDateRangeTo = $coupon['valid_end']; |
||||
|
||||
$includeSession = $plugin->get('include_sessions') === 'true'; |
||||
$includeServices = $plugin->get('include_services') === 'true'; |
||||
|
||||
$entityManager = Database::getManager(); |
||||
$userRepo = UserManager::getRepository(); |
||||
$currency = $plugin->getSelectedCurrency(); |
||||
|
||||
if (empty($currency)) { |
||||
Display::addFlash( |
||||
Display::return_message($plugin->get_lang('CurrencyIsNotConfigured'), 'error') |
||||
); |
||||
} |
||||
|
||||
$currencyIso = null; |
||||
|
||||
$coursesList = CourseManager::get_courses_list( |
||||
0, |
||||
0, |
||||
'title', |
||||
'asc', |
||||
-1, |
||||
null, |
||||
api_get_current_access_url_id(), |
||||
false, |
||||
[], |
||||
[] |
||||
); |
||||
|
||||
foreach ($coursesList as $course) { |
||||
$courses[$course['id']] = $course['title']; |
||||
} |
||||
|
||||
$sessionsList = SessionManager::get_sessions_list( |
||||
[], |
||||
[], |
||||
null, |
||||
null, |
||||
api_get_current_access_url_id(), |
||||
[] |
||||
); |
||||
|
||||
foreach ($sessionsList as $session) { |
||||
$sessions[$session['id']] = $session['name']; |
||||
} |
||||
|
||||
$servicesList = $plugin->getAllServices(); |
||||
|
||||
foreach ($servicesList as $service) { |
||||
$services[$service['id']] = $service['name']; |
||||
} |
||||
|
||||
$discountTypes = $plugin->getCouponDiscountTypes(); |
||||
|
||||
// Build the form |
||||
$form = new FormValidator('add_coupon'); |
||||
$form->addText('code', $plugin->get_lang('CouponCode'), false); |
||||
$form->addText('discount_type', $plugin->get_lang('CouponDiscountType'), false); |
||||
$form->addText('discount_amount', $plugin->get_lang('CouponDiscount'), false); |
||||
$form->addDateRangePicker( |
||||
'date', |
||||
get_lang('Date'), |
||||
true, |
||||
[ |
||||
'value' => "$couponDateRangeFrom / $couponDateRangeTo", |
||||
] |
||||
); |
||||
|
||||
$form->addCheckBox('active', $plugin->get_lang('CouponActive')); |
||||
$form->addElement( |
||||
'advmultiselect', |
||||
'courses', |
||||
get_lang('Courses'), |
||||
$courses |
||||
); |
||||
|
||||
if ($includeSession) { |
||||
$form->addElement( |
||||
'advmultiselect', |
||||
'sessions', |
||||
get_lang('Sessions'), |
||||
$sessions |
||||
); |
||||
} |
||||
|
||||
if ($includeServices) { |
||||
$form->addElement( |
||||
'advmultiselect', |
||||
'services', |
||||
get_lang('Services'), |
||||
$services |
||||
); |
||||
} |
||||
|
||||
$form->addHidden('id', null); |
||||
|
||||
$coursesAdded = $coupon["courses"]; |
||||
if (!empty($coursesAdded)) { |
||||
$coursesAdded = array_column($coursesAdded, 'id'); |
||||
} |
||||
|
||||
$sessionsAdded = $coupon["sessions"]; |
||||
if (!empty($sessionsAdded)) { |
||||
$sessionsAdded = array_column($sessionsAdded, 'id'); |
||||
} |
||||
|
||||
$servicesAdded = $coupon["services"]; |
||||
if (!empty($servicesAdded)) { |
||||
$servicesAdded = array_column($servicesAdded, 'id'); |
||||
} |
||||
|
||||
$formDefaults = [ |
||||
'id' => $coupon['id'], |
||||
'code' => $coupon['code'], |
||||
'discount_type' => $discountTypes[$coupon['discount_type']], |
||||
'discount_amount' => $coupon['discount_amount'], |
||||
'date' => "$couponDateRangeFrom / $couponDateRangeTo", |
||||
'active' => $coupon['active'], |
||||
'courses' => $coursesAdded, |
||||
'sessions' => $sessionsAdded, |
||||
'services' => $servicesAdded, |
||||
]; |
||||
|
||||
$button = $form->addButtonSave(get_lang('Save')); |
||||
if (empty($currency)) { |
||||
$button->setAttribute('disabled'); |
||||
} |
||||
|
||||
$form->freeze(['code', 'discount_type', 'discount_amount']); |
||||
|
||||
if ($form->validate()) { |
||||
$formValues = $form->exportValues(); |
||||
|
||||
$coupon['id'] = $formValues['id']; |
||||
$coupon['valid_start'] = $formValues['date_start']; |
||||
$coupon['valid_end'] = $formValues['date_end']; |
||||
$coupon['active'] = $formValues['active']; |
||||
$coupon['courses'] = isset($formValues['courses']) ? $formValues['courses'] : []; |
||||
$coupon['sessions'] = isset($formValues['sessions']) ? $formValues['sessions'] : []; |
||||
$coupon['services'] = isset($formValues['services']) ? $formValues['services'] : []; |
||||
|
||||
$result = $plugin->updateCouponData($coupon); |
||||
|
||||
if ($result) { |
||||
Display::addFlash( |
||||
Display::return_message( |
||||
$plugin->get_lang('CouponUpdate'), |
||||
'success', |
||||
false |
||||
) |
||||
); |
||||
|
||||
header('Location: '.api_get_path(WEB_PLUGIN_PATH).'buycourses/src/configure_coupon.php?id='.$coupon["id"]); |
||||
} else { |
||||
header('Location:'.api_get_self().'?'.$queryString); |
||||
} |
||||
|
||||
exit; |
||||
} |
||||
|
||||
$form->setDefaults($formDefaults); |
||||
|
||||
$templateName = $plugin->get_lang('ConfigureCoupon'); |
||||
$interbreadcrumb[] = [ |
||||
'url' => 'paymentsetup.php', |
||||
'name' => get_lang('Configuration'), |
||||
]; |
||||
$interbreadcrumb[] = [ |
||||
'url' => 'coupons.php', |
||||
'name' => $plugin->get_lang('CouponList'), |
||||
]; |
||||
|
||||
$template = new Template($templateName); |
||||
$template->assign('header', $templateName); |
||||
$template->assign('content', $form->returnForm()); |
||||
$template->display_one_col_template(); |
||||
@ -0,0 +1,157 @@ |
||||
<?php |
||||
/* For license terms, see /license.txt */ |
||||
|
||||
/** |
||||
* Configuration script for the Buy Courses plugin. |
||||
* |
||||
* @package chamilo.plugin.buycourses |
||||
*/ |
||||
require_once '../config.php'; |
||||
|
||||
api_protect_admin_script(); |
||||
|
||||
$plugin = BuyCoursesPlugin::create(); |
||||
|
||||
$includeSession = $plugin->get('include_sessions') === 'true'; |
||||
$includeServices = $plugin->get('include_services') === 'true'; |
||||
|
||||
$entityManager = Database::getManager(); |
||||
$userRepo = UserManager::getRepository(); |
||||
$currency = $plugin->getSelectedCurrency(); |
||||
|
||||
if (empty($currency)) { |
||||
Display::addFlash( |
||||
Display::return_message($plugin->get_lang('CurrencyIsNotConfigured'), 'error') |
||||
); |
||||
} |
||||
|
||||
$currencyIso = null; |
||||
|
||||
$coursesList = CourseManager::get_courses_list( |
||||
0, |
||||
0, |
||||
'title', |
||||
'asc', |
||||
-1, |
||||
null, |
||||
api_get_current_access_url_id(), |
||||
false, |
||||
[], |
||||
[] |
||||
); |
||||
|
||||
foreach ($coursesList as $course) { |
||||
$courses[$course['id']] = $course['title']; |
||||
} |
||||
|
||||
$sessionsList = SessionManager::get_sessions_list( |
||||
[], |
||||
[], |
||||
null, |
||||
null, |
||||
api_get_current_access_url_id(), |
||||
[] |
||||
); |
||||
|
||||
foreach ($sessionsList as $session) { |
||||
$sessions[$session['id']] = $session['name']; |
||||
} |
||||
|
||||
$servicesList = $plugin->getAllServices(); |
||||
|
||||
foreach ($servicesList as $service) { |
||||
$services[$service['id']] = $service['name']; |
||||
} |
||||
|
||||
$discountTypes = $plugin->getCouponDiscountTypes(); |
||||
|
||||
// Build the form |
||||
$form = new FormValidator('add_coupon'); |
||||
$form->addText('code', $plugin->get_lang('CouponCode'), true); |
||||
$form->addRadio('discount_type', $plugin->get_lang('CouponDiscountType'), $discountTypes); |
||||
$form->addElement( |
||||
'number', |
||||
'discount_amount', |
||||
[$plugin->get_lang('CouponDiscount'), null, $currencyIso], |
||||
['step' => 1] |
||||
); |
||||
$form->addDateRangePicker('date', get_lang('Date'), true); |
||||
$form->addCheckBox('active', get_lang('Active')); |
||||
$form->addElement( |
||||
'advmultiselect', |
||||
'courses', |
||||
get_lang('Courses'), |
||||
$courses |
||||
); |
||||
|
||||
if ($includeSession) { |
||||
$form->addElement( |
||||
'advmultiselect', |
||||
'sessions', |
||||
get_lang('Sessions'), |
||||
$sessions |
||||
); |
||||
} |
||||
|
||||
if ($includeServices) { |
||||
$form->addElement( |
||||
'advmultiselect', |
||||
'services', |
||||
get_lang('Services'), |
||||
$services |
||||
); |
||||
} |
||||
|
||||
$button = $form->addButtonSave(get_lang('Save')); |
||||
|
||||
if (empty($currency)) { |
||||
$button->setAttribute('disabled'); |
||||
} |
||||
|
||||
if ($form->validate()) { |
||||
$formValues = $form->exportValues(); |
||||
|
||||
$coupon['code'] = $formValues['code']; |
||||
$coupon['discount_type'] = $formValues['discount_type']; |
||||
$coupon['discount_amount'] = $formValues['discount_amount']; |
||||
$coupon['valid_start'] = $formValues['date_start']; |
||||
$coupon['valid_end'] = $formValues['date_end']; |
||||
$coupon['active'] = $formValues['active']; |
||||
|
||||
if ($coupon['discount_type'] == BuyCoursesPlugin::COUPON_DISCOUNT_TYPE_PERCENTAGE && $coupon['discount_amount'] > 100) { |
||||
Display::addFlash( |
||||
Display::return_message($plugin->get_lang('CouponDiscountExceed100'), 'error', false) |
||||
); |
||||
} |
||||
|
||||
$coupon['courses'] = isset($formValues['courses']) ? $formValues['courses'] : []; |
||||
$coupon['sessions'] = isset($formValues['sessions']) ? $formValues['sessions'] : []; |
||||
$coupon['services'] = isset($formValues['services']) ? $formValues['services'] : []; |
||||
|
||||
$result = $plugin->addNewCoupon($coupon); |
||||
|
||||
if ($result) { |
||||
header('Location: '.api_get_path(WEB_PLUGIN_PATH).'buycourses/src/coupons.php'); |
||||
} else { |
||||
header('Location:'.api_get_self().'?'.$queryString); |
||||
} |
||||
|
||||
exit; |
||||
} |
||||
|
||||
$form->setDefaults($formDefaults); |
||||
|
||||
$templateName = $plugin->get_lang('CouponAdd'); |
||||
$interbreadcrumb[] = [ |
||||
'url' => 'paymentsetup.php', |
||||
'name' => get_lang('Configuration'), |
||||
]; |
||||
$interbreadcrumb[] = [ |
||||
'url' => 'coupons.php', |
||||
'name' => $plugin->get_lang('CouponList'), |
||||
]; |
||||
|
||||
$template = new Template($templateName); |
||||
$template->assign('header', $templateName); |
||||
$template->assign('content', $form->returnForm()); |
||||
$template->display_one_col_template(); |
||||
@ -0,0 +1,109 @@ |
||||
<?php |
||||
/* For license terms, see /license.txt */ |
||||
|
||||
/** |
||||
* List of couponsof the Buy Courses plugin. |
||||
* |
||||
* @package chamilo.plugin.buycourses |
||||
*/ |
||||
$cidReset = true; |
||||
|
||||
require_once '../config.php'; |
||||
|
||||
api_protect_admin_script(); |
||||
|
||||
$plugin = BuyCoursesPlugin::create(); |
||||
|
||||
if (isset($_GET['coupon_id'])) { |
||||
$coupon = $plugin->getCouponInfo($_GET['coupon_id']); |
||||
|
||||
if (empty($coupon)) { |
||||
api_not_allowed(true); |
||||
} |
||||
|
||||
$urlToRedirect = api_get_self().'?'; |
||||
|
||||
switch ($_GET['action']) { |
||||
case 'deactivate': |
||||
//activate coupon |
||||
break; |
||||
case 'activate': |
||||
//deactivate coupon |
||||
break; |
||||
} |
||||
|
||||
header("Location: $urlToRedirect"); |
||||
exit; |
||||
} |
||||
|
||||
$discountTypes = $plugin->getCouponDiscountTypes(); |
||||
$couponStatuses = $plugin->getCouponStatuses(); |
||||
|
||||
$selectedFilterType = '0'; |
||||
$selectedStatus = isset($_GET['status']) ? $_GET['status'] : BuyCoursesPlugin::COUPON_STATUS_ACTIVE; |
||||
|
||||
$form = new FormValidator('search', 'get'); |
||||
|
||||
if ($form->validate()) { |
||||
$selectedStatus = $form->getSubmitValue('status'); |
||||
|
||||
if ($selectedStatus === false) { |
||||
$selectedStatus = BuyCoursesPlugin::COUPON_STATUS_ACTIVE; |
||||
} |
||||
|
||||
if ($selectedFilterType === false) { |
||||
$selectedFilterType = '0'; |
||||
} |
||||
} |
||||
|
||||
$form->addHtml('<div id="report-by-status" '.($selectedFilterType !== '0' ? 'style="display:none"' : '').'>'); |
||||
$form->addSelect('status', $plugin->get_lang('CouponStatus'), $couponStatuses); |
||||
$form->addHtml('</div>'); |
||||
$form->addButtonFilter(get_lang('Search')); |
||||
$form->setDefaults([ |
||||
'filter_type' => $selectedFilterType, |
||||
'status' => $selectedStatus, |
||||
]); |
||||
|
||||
$coupons = $plugin->getCouponsListByStatus($selectedStatus); |
||||
$currency = $plugin->getSelectedCurrency(); |
||||
|
||||
foreach ($coupons as &$coupon) { |
||||
if ($coupon['discount_type'] == BuyCoursesPlugin::COUPON_DISCOUNT_TYPE_PERCENTAGE) { |
||||
$coupon['discount_value'] = $coupon['discount_amount']." %"; |
||||
} elseif ($coupon['discount_type'] == BuyCoursesPlugin::COUPON_DISCOUNT_TYPE_AMOUNT) { |
||||
$coupon['discount_value'] = $plugin->getPriceWithCurrencyFromIsoCode($coupon['discount_amount'], $currency['iso_code']); |
||||
} |
||||
$coupon['discount_type'] = $discountTypes[$coupon['discount_type']]; |
||||
} |
||||
|
||||
$interbreadcrumb[] = ['url' => '../index.php', 'name' => $plugin->get_lang('plugin_title')]; |
||||
|
||||
$htmlHeadXtra[] = api_get_css(api_get_path(WEB_PLUGIN_PATH).'buycourses/resources/css/style.css'); |
||||
|
||||
$templateName = $plugin->get_lang('CouponList'); |
||||
$template = new Template($templateName); |
||||
|
||||
$toolbar = Display::url( |
||||
Display::returnFontAwesomeIcon('fas fa-plus'). |
||||
get_lang('CouponAdd'), |
||||
api_get_path(WEB_PLUGIN_PATH).'buycourses/src/coupon_add.php', |
||||
['class' => 'btn btn-primary'] |
||||
); |
||||
|
||||
$template->assign( |
||||
'actions', |
||||
Display::toolbarAction('toolbar', [$toolbar]) |
||||
); |
||||
|
||||
$template->assign('form', $form->returnForm()); |
||||
$template->assign('selected_status', $selectedStatus); |
||||
$template->assign('coupon_list', $coupons); |
||||
$template->assign('coupon_status_active', BuyCoursesPlugin::COUPON_STATUS_ACTIVE); |
||||
$template->assign('coupon_status_disable', BuyCoursesPlugin::COUPON_STATUS_DISABLE); |
||||
|
||||
$content = $template->fetch('buycourses/view/coupons.tpl'); |
||||
|
||||
$template->assign('header', $templateName); |
||||
$template->assign('content', $content); |
||||
$template->display_one_col_template(); |
||||
@ -0,0 +1,96 @@ |
||||
<?php |
||||
/* For license terms, see /license.txt */ |
||||
|
||||
/** |
||||
* List of couponsof the Buy Courses plugin. |
||||
* |
||||
* @package chamilo.plugin.buycourses |
||||
*/ |
||||
$cidReset = true; |
||||
|
||||
require_once '../config.php'; |
||||
|
||||
api_protect_admin_script(); |
||||
|
||||
$plugin = BuyCoursesPlugin::create(); |
||||
|
||||
if (isset($_GET['coupon_id'])) { |
||||
$coupon = $plugin->getCouponInfo($_GET['coupon_id']); |
||||
|
||||
if (empty($coupon)) { |
||||
api_not_allowed(true); |
||||
} |
||||
|
||||
$urlToRedirect = api_get_self().'?'; |
||||
|
||||
switch ($_GET['action']) { |
||||
case 'deactivate': |
||||
//activate coupon |
||||
break; |
||||
case 'activate': |
||||
//deactivate coupon |
||||
break; |
||||
} |
||||
|
||||
header("Location: $urlToRedirect"); |
||||
exit; |
||||
} |
||||
|
||||
$discountTypes = $plugin->getCouponDiscountTypes(); |
||||
$couponStatuses = $plugin->getCouponStatuses(); |
||||
|
||||
$selectedFilterType = '0'; |
||||
$selectedStatus = isset($_GET['status']) ? $_GET['status'] : BuyCoursesPlugin::COUPON_STATUS_ACTIVE; |
||||
|
||||
$form = new FormValidator('search', 'get'); |
||||
|
||||
if ($form->validate()) { |
||||
$selectedStatus = $form->getSubmitValue('status'); |
||||
|
||||
if ($selectedStatus === false) { |
||||
$selectedStatus = BuyCoursesPlugin::COUPON_STATUS_ACTIVE; |
||||
} |
||||
|
||||
if ($selectedFilterType === false) { |
||||
$selectedFilterType = '0'; |
||||
} |
||||
} |
||||
|
||||
$form->addHtml('<div id="report-by-status" '.($selectedFilterType !== '0' ? 'style="display:none"' : '').'>'); |
||||
$form->addSelect('status', $plugin->get_lang('CouponStatus'), $couponStatuses); |
||||
$form->addHtml('</div>'); |
||||
$form->addButtonFilter(get_lang('Search')); |
||||
$form->setDefaults([ |
||||
'filter_type' => $selectedFilterType, |
||||
'status' => $selectedStatus, |
||||
]); |
||||
|
||||
$coupons = $plugin->getCouponsListByStatus($selectedStatus); |
||||
|
||||
foreach ($coupons as &$coupon) { |
||||
if ($coupon['discount_type'] == BuyCoursesPlugin::COUPON_DISCOUNT_TYPE_PERCENTAGE) { |
||||
$coupon['discount_value'] = $coupon['discount_amount']." %"; |
||||
} elseif ($coupon['discount_type'] == BuyCoursesPlugin::COUPON_DISCOUNT_TYPE_AMOUNT) { |
||||
$coupon['discount_value'] = $plugin->getPriceWithCurrencyFromIsoCode($coupon['discount_amount'], $coupon['iso_code']); |
||||
} |
||||
$coupon['discount_type'] = $discountTypes[$coupon['discount_type']]; |
||||
} |
||||
|
||||
$interbreadcrumb[] = ['url' => '../index.php', 'name' => $plugin->get_lang('plugin_title')]; |
||||
|
||||
$htmlHeadXtra[] = api_get_css(api_get_path(WEB_PLUGIN_PATH).'buycourses/resources/css/style.css'); |
||||
|
||||
$templateName = $plugin->get_lang('CouponList'); |
||||
$template = new Template($templateName); |
||||
|
||||
$template->assign('form', $form->returnForm()); |
||||
$template->assign('selected_status', $selectedStatus); |
||||
$template->assign('coupon_list', $coupons); |
||||
$template->assign('coupon_status_active', BuyCoursesPlugin::COUPON_STATUS_ACTIVE); |
||||
$template->assign('coupon_status_disable', BuyCoursesPlugin::COUPON_STATUS_DISABLE); |
||||
|
||||
$content = $template->fetch('buycourses/view/list_coupon.tpl'); |
||||
|
||||
$template->assign('header', $templateName); |
||||
$template->assign('content', $content); |
||||
$template->display_one_col_template(); |
||||
@ -0,0 +1,39 @@ |
||||
<br /> |
||||
<br /> |
||||
{{ form }} |
||||
|
||||
<div class="table-responsive"> |
||||
<table class="table table-striped table-hover"> |
||||
<thead> |
||||
<tr class="sale-columns"> |
||||
<th>{{ 'CouponCode'|get_plugin_lang('BuyCoursesPlugin') }}</th> |
||||
<th>{{ 'CouponDiscountType'|get_plugin_lang('BuyCoursesPlugin') }}</th> |
||||
<th>{{ 'CouponDiscount'|get_plugin_lang('BuyCoursesPlugin') }}</th> |
||||
<th>{{ 'CouponDateStart'|get_plugin_lang('BuyCoursesPlugin') }}</th> |
||||
<th>{{ 'CouponDateEnd'|get_plugin_lang('BuyCoursesPlugin') }}</th> |
||||
<th>{{ 'CouponDelivered'|get_plugin_lang('BuyCoursesPlugin') }}</th> |
||||
<th width="10%">{{ 'Options'|get_lang }}</th> |
||||
</tr> |
||||
</thead> |
||||
<tbody> |
||||
{% for coupon in coupon_list %} |
||||
<tr class="sale-row"> |
||||
<td class="text-center">{{ coupon.code }}</td> |
||||
<td class="text-center">{{ coupon.discount_type }}</td> |
||||
<td class="text-center">{{ coupon.discount_value }}</td> |
||||
<td class="text-center">{{ coupon.valid_start | api_get_local_time }}</td> |
||||
<td class="text-center">{{ coupon.valid_end | api_get_local_time }}</td> |
||||
<td class="text-center">{{ coupon.delivered }}</td> |
||||
<td class="text-center"> |
||||
<div class="btn-group btn-group-xs" role="group" aria-label="..."> |
||||
<a title="{{ 'ConfigureCoupon'|get_plugin_lang('BuyCoursesPlugin') }}" href="{{ _p.web_plugin ~ 'buycourses/src/configure_coupon.php?' ~ {'id': coupon.id}|url_encode() }}" |
||||
class="btn btn-default"> |
||||
<em class="fa fa-wrench fa-fw"></em> |
||||
</a> |
||||
</div> |
||||
</td> |
||||
</tr> |
||||
{% endfor %} |
||||
</tbody> |
||||
</table> |
||||
</div> |
||||
@ -0,0 +1,49 @@ |
||||
<br /> |
||||
<br /> |
||||
{{ form }} |
||||
|
||||
<div class="table-responsive"> |
||||
<table class="table table-striped table-hover"> |
||||
<thead> |
||||
<tr class="sale-columns"> |
||||
<th>{{ 'CouponCode'|get_plugin_lang('BuyCoursesPlugin') }}</th> |
||||
<th>{{ 'CouponDiscountType'|get_plugin_lang('BuyCoursesPlugin') }}</th> |
||||
<th>{{ 'CouponDiscount'|get_plugin_lang('BuyCoursesPlugin') }}</th> |
||||
<th>{{ 'CouponDateStart'|get_plugin_lang('BuyCoursesPlugin') }}</th> |
||||
<th>{{ 'CouponDateEnd'|get_plugin_lang('BuyCoursesPlugin') }}</th> |
||||
<th>{{ 'CouponDelivered'|get_plugin_lang('BuyCoursesPlugin') }}</th> |
||||
<th width="10%">{{ 'Options'|get_lang }}</th> |
||||
</tr> |
||||
</thead> |
||||
<tbody> |
||||
{% for coupon in coupon_list %} |
||||
<tr class="sale-row"> |
||||
<td class="text-center">{{ coupon.code }}</td> |
||||
<td class="text-center">{{ coupon.discount_type }}</td> |
||||
<td class="text-center">{{ coupon.discount_value }}</td> |
||||
<td class="text-center">{{ coupon.valid_start | api_get_local_time }}</td> |
||||
<td class="text-center">{{ coupon.valid_end | api_get_local_time }}</td> |
||||
<td class="text-center">{{ coupon.delivered }}</td> |
||||
<td class="text-center"> |
||||
{% if coupon.active == coupon_status_active %} |
||||
<div class="btn-group btn-group-xs" role="group" aria-label="..."> |
||||
<a title="{{ 'CouponDisable'|get_plugin_lang('BuyCoursesPlugin') }}" href="{{ _p.web_self ~ '?' ~ {'coupon': coupon.id, 'action': 'deactivate'}|url_encode() }}" |
||||
class="btn btn-default"> |
||||
<img src="{{ 'user_subscribe_session.png' | icon(22) }}" width="22" height="22 alt="{{ 'CouponDisable'|get_plugin_lang('BuyCoursesPlugin') }}"> |
||||
</a> |
||||
</div> |
||||
{% endif %} |
||||
{% if coupon.active == coupon_status_disable %} |
||||
<div class="btn-group btn-group-xs" role="group" aria-label="..."> |
||||
<a title="{{ 'CouponEnable'|get_plugin_lang('BuyCoursesPlugin') }}" href="{{ _p.web_self ~ '?' ~ {'coupon': coupon.id, 'action': 'activate'}|url_encode() }}" |
||||
class="btn btn-default"> |
||||
<img src="{{ 'user_subscribe_session.png' | icon(22) }}" width="22" height="22 alt="{{ 'CouponEnable'|get_plugin_lang('BuyCoursesPlugin') }}"> |
||||
</a> |
||||
</div> |
||||
{% endif %} |
||||
</td> |
||||
</tr> |
||||
{% endfor %} |
||||
</tbody> |
||||
</table> |
||||
</div> |
||||
Loading…
Reference in new issue