Merge branch '10563' of https://github.com/jloguercio/chamilo-lms into jloguercio-10563
commit
73539bbbc1
@ -1,3 +1,275 @@ |
||||
.buy-courses-tabs { |
||||
margin-bottom: 15px; |
||||
} |
||||
|
||||
// spinner wobblebar |
||||
|
||||
@-moz-keyframes wobblebar-loader { |
||||
0% { |
||||
left: 4px; |
||||
} |
||||
3% { |
||||
left: 204px; |
||||
} |
||||
6% { |
||||
left: 4px; |
||||
} |
||||
9% { |
||||
left: 204px; |
||||
} |
||||
12% { |
||||
left: 4px; |
||||
} |
||||
15% { |
||||
left: 204px; |
||||
} |
||||
18% { |
||||
left: 32px; |
||||
} |
||||
27% { |
||||
left: 32px; |
||||
} |
||||
30% { |
||||
left: 204px; |
||||
} |
||||
33% { |
||||
left: 4px; |
||||
} |
||||
36% { |
||||
left: 204px; |
||||
} |
||||
39% { |
||||
left: 4px; |
||||
} |
||||
42% { |
||||
left: 204px; |
||||
} |
||||
45% { |
||||
left: 4px; |
||||
} |
||||
48% { |
||||
left: 204px; |
||||
} |
||||
51% { |
||||
left: 152px; |
||||
} |
||||
63% { |
||||
left: 152px; |
||||
} |
||||
66% { |
||||
left: 4px; |
||||
} |
||||
69% { |
||||
left: 204px; |
||||
} |
||||
72% { |
||||
left: 4px; |
||||
} |
||||
75% { |
||||
left: 204px; |
||||
} |
||||
78% { |
||||
left: 4px; |
||||
} |
||||
81% { |
||||
left: 204px; |
||||
} |
||||
84% { |
||||
left: 72px; |
||||
} |
||||
94% { |
||||
left: 72px; |
||||
} |
||||
97% { |
||||
left: 204px; |
||||
} |
||||
} |
||||
@-webkit-keyframes wobblebar-loader { |
||||
0% { |
||||
left: 4px; |
||||
} |
||||
3% { |
||||
left: 204px; |
||||
} |
||||
6% { |
||||
left: 4px; |
||||
} |
||||
9% { |
||||
left: 204px; |
||||
} |
||||
12% { |
||||
left: 4px; |
||||
} |
||||
15% { |
||||
left: 204px; |
||||
} |
||||
18% { |
||||
left: 32px; |
||||
} |
||||
27% { |
||||
left: 32px; |
||||
} |
||||
30% { |
||||
left: 204px; |
||||
} |
||||
33% { |
||||
left: 4px; |
||||
} |
||||
36% { |
||||
left: 204px; |
||||
} |
||||
39% { |
||||
left: 4px; |
||||
} |
||||
42% { |
||||
left: 204px; |
||||
} |
||||
45% { |
||||
left: 4px; |
||||
} |
||||
48% { |
||||
left: 204px; |
||||
} |
||||
51% { |
||||
left: 152px; |
||||
} |
||||
63% { |
||||
left: 152px; |
||||
} |
||||
66% { |
||||
left: 4px; |
||||
} |
||||
69% { |
||||
left: 204px; |
||||
} |
||||
72% { |
||||
left: 4px; |
||||
} |
||||
75% { |
||||
left: 204px; |
||||
} |
||||
78% { |
||||
left: 4px; |
||||
} |
||||
81% { |
||||
left: 204px; |
||||
} |
||||
84% { |
||||
left: 72px; |
||||
} |
||||
94% { |
||||
left: 72px; |
||||
} |
||||
97% { |
||||
left: 204px; |
||||
} |
||||
} |
||||
@keyframes wobblebar-loader { |
||||
0% { |
||||
left: 4px; |
||||
} |
||||
3% { |
||||
left: 204px; |
||||
} |
||||
6% { |
||||
left: 4px; |
||||
} |
||||
9% { |
||||
left: 204px; |
||||
} |
||||
12% { |
||||
left: 4px; |
||||
} |
||||
15% { |
||||
left: 204px; |
||||
} |
||||
18% { |
||||
left: 32px; |
||||
} |
||||
27% { |
||||
left: 32px; |
||||
} |
||||
30% { |
||||
left: 204px; |
||||
} |
||||
33% { |
||||
left: 4px; |
||||
} |
||||
36% { |
||||
left: 204px; |
||||
} |
||||
39% { |
||||
left: 4px; |
||||
} |
||||
42% { |
||||
left: 204px; |
||||
} |
||||
45% { |
||||
left: 4px; |
||||
} |
||||
48% { |
||||
left: 204px; |
||||
} |
||||
51% { |
||||
left: 152px; |
||||
} |
||||
63% { |
||||
left: 152px; |
||||
} |
||||
66% { |
||||
left: 4px; |
||||
} |
||||
69% { |
||||
left: 204px; |
||||
} |
||||
72% { |
||||
left: 4px; |
||||
} |
||||
75% { |
||||
left: 204px; |
||||
} |
||||
78% { |
||||
left: 4px; |
||||
} |
||||
81% { |
||||
left: 204px; |
||||
} |
||||
84% { |
||||
left: 72px; |
||||
} |
||||
94% { |
||||
left: 72px; |
||||
} |
||||
97% { |
||||
left: 204px; |
||||
} |
||||
} |
||||
/* :not(:required) hides this rule from IE9 and below */ |
||||
.wobblebar-loader:not(:required) { |
||||
background: #2E6DA4; |
||||
-moz-border-radius: 10.66667px; |
||||
-webkit-border-radius: 10.66667px; |
||||
border-radius: 10.66667px; |
||||
display: inline-block; |
||||
overflow: hidden; |
||||
text-indent: -9999px; |
||||
width: 228px; |
||||
height: 21.33333px; |
||||
position: relative; |
||||
} |
||||
.wobblebar-loader:not(:required)::after { |
||||
-moz-animation: wobblebar-loader 15000ms infinite ease; |
||||
-webkit-animation: wobblebar-loader 15000ms infinite ease; |
||||
animation: wobblebar-loader 15000ms infinite ease; |
||||
background: white; |
||||
display: block; |
||||
-moz-border-radius: 7.11111px; |
||||
-webkit-border-radius: 7.11111px; |
||||
border-radius: 7.11111px; |
||||
content: ''; |
||||
position: absolute; |
||||
top: 3.55556px; |
||||
left: 4px; |
||||
width: 21.33333px; |
||||
height: 14.22222px; |
||||
} |
||||
|
@ -0,0 +1,131 @@ |
||||
/* |
||||
* To change this license header, choose License Headers in Project Properties. |
||||
* To change this template file, choose Tools | Templates |
||||
* and open the template in the editor. |
||||
*/ |
||||
|
||||
function showSliders(maxPercentage, type, defaultValues) { |
||||
|
||||
defaultValues = defaultValues || "0"; |
||||
|
||||
var sliderCounter = 1; |
||||
var percentage = 0; |
||||
var minPercentage = 0; |
||||
|
||||
$("#selectBox option:selected").each(function() { |
||||
|
||||
var count = $("#selectBox option:selected").length; |
||||
|
||||
percentage = maxPercentage / count; |
||||
percentage = parseInt(percentage); |
||||
|
||||
verifyMaxPercentage = percentage * count; |
||||
if (verifyMaxPercentage !== maxPercentage && sliderCounter === 1) { |
||||
percentage = percentage + (maxPercentage - verifyMaxPercentage); |
||||
} |
||||
|
||||
beneficiaryId = $(this).val(); |
||||
beneficiaryName = $(this).text(); |
||||
|
||||
|
||||
var slidersValue = defaultValues.toString().split(','); |
||||
|
||||
if (type === 'default') { |
||||
|
||||
percentage = slidersValue[sliderCounter - 1]; |
||||
percentage = parseInt(percentage); |
||||
$("#panelSliders").append("<span>" + beneficiaryName + "</span> - [ <span class='value' >" + percentage + "</span> % ]<div id=" + beneficiaryId + " class='panelSliders'></div>"); |
||||
|
||||
} else if (type === 'renew') { |
||||
|
||||
$("#panelSliders").append("<span>" + beneficiaryName + "</span> - [ <span class='value' >" + percentage + "</span> % ]<div id=" + beneficiaryId + " class='panelSliders'></div>"); |
||||
|
||||
} |
||||
|
||||
sliderCounter++; |
||||
stepSlide = count - 1; |
||||
|
||||
if (stepSlide === 0) { |
||||
(type === 'default') ? minPercentage = 0 : minPercentage = 100; |
||||
(type === 'default') ? stepSlide = 100 : stepSlide = 1; |
||||
} |
||||
|
||||
|
||||
$( "#panelSliders .panelSliders" ).slider({ |
||||
value: percentage, |
||||
min: minPercentage, |
||||
max: maxPercentage, |
||||
step: stepSlide, |
||||
animate: true, |
||||
slide: function( event, ui ) { |
||||
|
||||
$(this).prev(".value").text(ui.value); |
||||
|
||||
var total = 0; |
||||
var sliders = $( "#panelSliders .panelSliders" ); |
||||
|
||||
sliders.not(this).each(function() { |
||||
value = $(this).slider("option", "value"); |
||||
total += value; |
||||
}); |
||||
|
||||
total += ui.value; |
||||
var delta = 100 - total; |
||||
|
||||
sliders.not(this).each(function() { |
||||
|
||||
var t = $(this); |
||||
value = t.slider("option", "value"); |
||||
|
||||
var newValue = value + (delta/stepSlide); |
||||
|
||||
if (newValue < 0 || ui.value == 100)
|
||||
newValue = 0; |
||||
if (newValue > 100)
|
||||
newValue = 100; |
||||
|
||||
t.prev('.value').text(newValue); |
||||
t.slider('value', newValue); |
||||
|
||||
}); |
||||
|
||||
$("[name=\'comissions\']").val(getSlidersValues()); |
||||
} |
||||
}); |
||||
}); |
||||
|
||||
$("[name=\'comissions\']").val(getSlidersValues()); |
||||
showCorrectSliderHandler(); |
||||
}; |
||||
|
||||
function getSlidersValues() { |
||||
var comissions = ""; |
||||
|
||||
$( "#panelSliders .panelSliders" ).each(function() { |
||||
comissions += $(this).prev(".value").text() + ','; |
||||
}); |
||||
|
||||
comissions = comissions.substring(0, comissions.length-1); |
||||
|
||||
return comissions; |
||||
} |
||||
|
||||
function showCorrectSliderHandler() { |
||||
var correctHandler = []; |
||||
|
||||
$("#panelSliders > span").each(function () { |
||||
if ($(this).hasClass('value')) { |
||||
correctHandler.push($(this).text()); |
||||
} |
||||
}); |
||||
|
||||
var counter = 0; |
||||
|
||||
$("#panelSliders .panelSliders > span").each(function () { |
||||
if ($(this).hasClass('ui-slider-handle')) { |
||||
$(this).css('left', correctHandler[counter]+'%'); |
||||
counter++; |
||||
} |
||||
}); |
||||
|
||||
} |
@ -0,0 +1,226 @@ |
||||
<?php |
||||
|
||||
/* For licensing terms, see /chamilo_license.txt */ |
||||
/** |
||||
* Responses to AJAX calls |
||||
* @package chamilo.plugin.buycourses |
||||
*/ |
||||
|
||||
$cidReset = true; |
||||
|
||||
require_once '../../../main/inc/global.inc.php'; |
||||
|
||||
api_protect_admin_script(true); |
||||
|
||||
$plugin = BuyCoursesPlugin::create(); |
||||
|
||||
$paypalEnable = $plugin->get('paypal_enable'); |
||||
$comissionsEnable = $plugin->get('comissions_enable'); |
||||
|
||||
$action = isset($_GET['a']) ? $_GET['a'] : null; |
||||
|
||||
switch ($action) { |
||||
case 'saleInfo': |
||||
if (api_is_anonymous()) { |
||||
break; |
||||
} |
||||
|
||||
$saleId = isset($_POST['id']) ? $_POST['id'] : ''; |
||||
$sale = $plugin->getSale($saleId); |
||||
$productType = ($sale['product_type'] == 1) ? get_lang('Course') : get_lang('Session'); |
||||
$paymentType = ($sale['payment_type'] == 1) ? 'Paypal' : $plugin->get_lang('BankTransfer'); |
||||
$productInfo = ($sale['product_type'] == 1) ? api_get_course_info_by_id($sale['product_id']) : api_get_session_info($sale['product_id']); |
||||
$currency = $plugin->getSelectedCurrency(); |
||||
if ($sale['product_type'] == 1) { |
||||
$productImage = $productInfo['course_image_large']; |
||||
} else { |
||||
$productImage = ($productInfo['image']) ? $productInfo['image'] : Template::get_icon_path('session_default.png'); |
||||
} |
||||
|
||||
$userInfo = api_get_user_info($sale['user_id']); |
||||
|
||||
$html = '<h2>' . $sale['product_name'] .'</h2>'; |
||||
$html .= '<div class="row">'; |
||||
$html .= '<div class="col-sm-6 col-md-6">'; |
||||
$html .= '<ul>'; |
||||
$html .= '<li><b>'. $plugin->get_lang('OrderPrice') . ':</b> '. $sale['price'] . '</li>'; |
||||
$html .= '<li><b>'. $plugin->get_lang('CurrencyType') . ':</b> '. $currency['iso_code'] . '</li>'; |
||||
$html .= '<li><b>'. $plugin->get_lang('ProductType') . ':</b> '. $productType . '</li>'; |
||||
$html .= '<li><b>'. $plugin->get_lang('OrderDate') . ':</b> '. api_format_date($sale['date'], DATE_TIME_FORMAT_LONG_24H) . '</li>'; |
||||
$html .= '<li><b>'. $plugin->get_lang('Buyer') . ':</b> '. $userInfo['complete_name'] . '</li>'; |
||||
$html .= '<li><b>'. $plugin->get_lang('PaymentMethods') . ':</b> '. $paymentType . '</li>'; |
||||
$html .= '</ul>'; |
||||
$html .= '</div>'; |
||||
$html .= '<div class="col-sm-6 col-md-6">'; |
||||
$html .= '<img class="thumbnail" src="'. $productImage .'" >'; |
||||
$html .= '</div>'; |
||||
$html .= '</div>'; |
||||
|
||||
echo $html; |
||||
|
||||
break; |
||||
|
||||
case 'stats': |
||||
if (api_is_anonymous()) { |
||||
break; |
||||
} |
||||
|
||||
$stats = []; |
||||
$stats['completed_count'] = 0; |
||||
$stats['completed_total_amount'] = 0; |
||||
$stats['pending_count'] = 0; |
||||
$stats['pending_total_amount'] = 0; |
||||
$stats['canceled_count'] = 0; |
||||
$stats['canceled_total_amount'] = 0; |
||||
|
||||
$completedPayouts = $plugin->getPayouts(BuyCoursesPlugin::PAYOUT_STATUS_COMPLETED); |
||||
$pendingPayouts = $plugin->getPayouts(BuyCoursesPlugin::PAYOUT_STATUS_PENDING); |
||||
$canceledPayouts = $plugin->getPayouts(BuyCoursesPlugin::PAYOUT_STATUS_CANCELED); |
||||
$currency = $plugin->getSelectedCurrency(); |
||||
|
||||
foreach ($completedPayouts as $completed) { |
||||
$stats['completed_count'] = count($completedPayouts); |
||||
$stats['completed_total_amount'] += $completed['comission']; |
||||
$stats['completed_total_amount'] = number_format($stats['completed_total_amount'], 2); |
||||
} |
||||
|
||||
foreach ($pendingPayouts as $pending) { |
||||
$stats['pending_count'] = count($pendingPayouts); |
||||
$stats['pending_total_amount'] += $pending['comission']; |
||||
$stats['pending_total_amount'] = number_format($stats['pending_total_amount'], 2); |
||||
} |
||||
|
||||
foreach ($canceledPayouts as $canceled) { |
||||
$stats['canceled_count'] = count($canceledPayouts); |
||||
$stats['canceled_total_amount'] += $canceled['comission']; |
||||
$stats['canceled_total_amount'] = number_format($stats['canceled_total_amount'], 2); |
||||
} |
||||
|
||||
|
||||
$html = '<div class="row">' |
||||
. '<p>' |
||||
. '<ul>' |
||||
. '<li>'. get_plugin_lang("PayoutsTotalCompleted", "BuyCoursesPlugin") .' <b>'. $stats['completed_count'] .'</b> - '. get_plugin_lang("TotalAmount", "BuyCoursesPlugin") .' <b>'. $stats['completed_total_amount'] .' '. $currency['iso_code'] . '</b></li>' |
||||
. '<li>'. get_plugin_lang("PayoutsTotalPending", "BuyCoursesPlugin") .' <b>'. $stats['pending_count'] .'</b> - '. get_plugin_lang("TotalAmount", "BuyCoursesPlugin") .' <b>'. $stats['pending_total_amount'] .' '. $currency['iso_code'] . '</b></li>' |
||||
. '<li>'. get_plugin_lang("PayoutsTotalCanceled", "BuyCoursesPlugin") .' <b>'. $stats['canceled_count'] .'</b> - '. get_plugin_lang("TotalAmount", "BuyCoursesPlugin") .' <b>'. $stats['canceled_total_amount'] .' '. $currency['iso_code'] . '</b></li>' |
||||
. '</ul>' |
||||
. '</p>'; |
||||
$html .= '</div>'; |
||||
echo $html; |
||||
|
||||
break; |
||||
|
||||
case 'processPayout': |
||||
if (api_is_anonymous()) { |
||||
break; |
||||
} |
||||
|
||||
$html = ''; |
||||
$allPays = []; |
||||
$totalAccounts = 0; |
||||
$totalPayout = 0; |
||||
|
||||
$payouts = isset($_POST['payouts']) ? $_POST['payouts'] : ''; |
||||
|
||||
if (!$payouts) { |
||||
|
||||
echo Display::return_message(get_plugin_lang("SelectOptionToProceed", "BuyCoursesPlugin"), 'error', false); |
||||
|
||||
break; |
||||
} |
||||
|
||||
foreach($payouts as $index => $id) { |
||||
$allPays[] = $plugin->getPayouts(BuyCoursesPlugin::PAYOUT_STATUS_PENDING, $id); |
||||
} |
||||
|
||||
foreach($allPays as $payout) { |
||||
$totalPayout += number_format($payout['comission'], 2); |
||||
$totalAccounts++; |
||||
} |
||||
|
||||
$currentCurrency = $plugin->getSelectedCurrency(); |
||||
|
||||
$isoCode = $currentCurrency['iso_code']; |
||||
|
||||
$html .= '<p>'. get_plugin_lang("VerifyTotalAmountToProceedPayout", "BuyCoursesPlugin") .'</p>'; |
||||
$html .= '' |
||||
. '<p>' |
||||
. '<ul>' |
||||
. '<li>'. get_plugin_lang("TotalAcounts", "BuyCoursesPlugin") .' <b>'. $totalAccounts .'</b></li>' |
||||
. '<li>'. get_plugin_lang("TotalPayout", "BuyCoursesPlugin") .' <b>'. $isoCode .' '. $totalPayout .'</b></li>' |
||||
. '</ul>' |
||||
. '</p>'; |
||||
$html .= '<p>'. get_plugin_lang("CautionThisProcessCantBeCanceled", "BuyCoursesPlugin") .'</p>'; |
||||
$html .= '</br></br>'; |
||||
$html .= '<div id="spinner" class="text-center"></div>'; |
||||
|
||||
echo $html; |
||||
break; |
||||
|
||||
case 'proceedPayout': |
||||
if (api_is_anonymous()) { |
||||
break; |
||||
} |
||||
|
||||
$paypalParams = $plugin->getPaypalParams(); |
||||
|
||||
$pruebas = $paypalParams['sandbox'] == 1; |
||||
$paypalUsername = $paypalParams['username']; |
||||
$paypalPassword = $paypalParams['password']; |
||||
$paypalSignature = $paypalParams['signature']; |
||||
|
||||
require_once("paypalfunctions.php"); |
||||
|
||||
$allPayouts = []; |
||||
$totalAccounts = 0; |
||||
$totalPayout = 0; |
||||
|
||||
$payouts = isset($_POST['payouts']) ? $_POST['payouts'] : ''; |
||||
|
||||
if (!$payouts) { |
||||
|
||||
echo Display::return_message(get_plugin_lang("SelectOptionToProceed", "BuyCoursesPlugin"), 'error', false); |
||||
|
||||
break; |
||||
} |
||||
|
||||
foreach($payouts as $index => $id) { |
||||
$allPayouts[] = $plugin->getPayouts(BuyCoursesPlugin::PAYOUT_STATUS_PENDING, $id); |
||||
} |
||||
|
||||
$currentCurrency = $plugin->getSelectedCurrency(); |
||||
|
||||
$isoCode = $currentCurrency['iso_code']; |
||||
|
||||
|
||||
$result = MassPayment($allPayouts, $isoCode); |
||||
|
||||
if($result['ACK'] === 'Success') { |
||||
foreach($allPayouts as $payout) { |
||||
$plugin->setStatusPayouts($payout['id'], BuyCoursesPlugin::PAYOUT_STATUS_COMPLETED); |
||||
} |
||||
|
||||
echo Display::return_message(get_plugin_lang("PayoutSuccess", "BuyCoursesPlugin"), 'success', false); |
||||
|
||||
} else { |
||||
|
||||
echo Display::return_message('<b>'.$result['L_SEVERITYCODE0'].' '.$result['L_ERRORCODE0'].'</b> - '.$result['L_SHORTMESSAGE0'].'</br><ul><li>'. $result['L_LONGMESSAGE0'].'</li></ul>', 'error', false); |
||||
|
||||
} |
||||
|
||||
break; |
||||
|
||||
case 'cancelPayout': |
||||
if (api_is_anonymous()) { |
||||
break; |
||||
} |
||||
|
||||
$payoutId = isset($_POST['id']) ? $_POST['id'] : ''; |
||||
|
||||
$plugin->setStatusPayouts($payoutId, BuyCoursesPlugin::PAYOUT_STATUS_CANCELED); |
||||
|
||||
echo ''; |
||||
|
||||
break; |
||||
} |
||||
exit; |
@ -0,0 +1,61 @@ |
||||
<?php |
||||
/** |
||||
* User Panel |
||||
* @package chamilo.plugin.buycourses |
||||
*/ |
||||
/** |
||||
* Initialization |
||||
*/ |
||||
|
||||
$cidReset = true; |
||||
|
||||
require_once '../../../main/inc/global.inc.php'; |
||||
|
||||
$plugin = BuyCoursesPlugin::create(); |
||||
$includeSessions = $plugin->get('include_sessions') === 'true'; |
||||
|
||||
$userInfo = api_get_user_info(); |
||||
|
||||
$productTypes = $plugin->getProductTypes(); |
||||
$saleStatuses = $plugin->getSaleStatuses(); |
||||
$paymentTypes = $plugin->getPaymentTypes(); |
||||
|
||||
$sales = $plugin->getSaleListByUserId($userInfo['id']); |
||||
|
||||
$saleList = []; |
||||
|
||||
foreach ($sales as $sale) { |
||||
if ($sale['product_type'] == 1) { |
||||
$saleList[] = [ |
||||
'id' => $sale['id'], |
||||
'reference' => $sale['reference'], |
||||
'date' => api_format_date($sale['date'], DATE_TIME_FORMAT_LONG_24H), |
||||
'currency' => $sale['iso_code'], |
||||
'price' => $sale['price'], |
||||
'product_name' => $sale['product_name'], |
||||
'product_type' => $productTypes[$sale['product_type']], |
||||
'payment_type' => $paymentTypes[$sale['payment_type']] |
||||
]; |
||||
} |
||||
} |
||||
|
||||
$toolbar = Display::toolbarButton( |
||||
$plugin->get_lang('CourseListOnSale'), |
||||
'course_catalog.php', |
||||
'search-plus', |
||||
'primary', |
||||
['title' => $plugin->get_lang('CourseListOnSale')] |
||||
); |
||||
|
||||
$templateName = get_lang('TabsDashboard'); |
||||
$tpl = new Template($templateName); |
||||
$tpl->assign('showing_courses', true); |
||||
$tpl->assign('sessions_are_included', $includeSessions); |
||||
$tpl->assign('sale_list', $saleList); |
||||
|
||||
$content = $tpl->fetch('buycourses/view/course_panel.tpl'); |
||||
|
||||
$tpl->assign('actions', $toolbar); |
||||
$tpl->assign('header', $templateName); |
||||
$tpl->assign('content', $content); |
||||
$tpl->display_one_col_template(); |
@ -0,0 +1,220 @@ |
||||
<?php |
||||
|
||||
/* For licensing terms, see /chamilo_license.txt */ |
||||
/** |
||||
* Responses to AJAX calls |
||||
* @package chamilo.plugin.buycourses |
||||
*/ |
||||
|
||||
$cidReset = true; |
||||
|
||||
require_once '../../../main/inc/global.inc.php'; |
||||
|
||||
api_protect_admin_script(true); |
||||
|
||||
$plugin = BuyCoursesPlugin::create(); |
||||
|
||||
$paypalEnable = $plugin->get('paypal_enable'); |
||||
$comissionsEnable = $plugin->get('comissions_enable'); |
||||
|
||||
$action = isset($_GET['a']) ? $_GET['a'] : null; |
||||
|
||||
switch ($action) { |
||||
case 'saleInfo': |
||||
|
||||
$saleId = isset($_POST['id']) ? $_POST['id'] : ''; |
||||
$sale = $plugin->getSale($saleId); |
||||
$productType = ($sale['product_type'] == 1) ? get_lang('Course') : get_lang('Session'); |
||||
$paymentType = ($sale['payment_type'] == 1) ? 'Paypal' : $plugin->get_lang('BankTransfer'); |
||||
$productInfo = ($sale['product_type'] == 1) ? api_get_course_info_by_id($sale['product_id']) : api_get_session_info($sale['product_id']); |
||||
$currency = $plugin->getSelectedCurrency(); |
||||
if ($sale['product_type'] == 1) { |
||||
$productImage = $productInfo['course_image_large']; |
||||
} else { |
||||
$productImage = ($productInfo['image']) ? $productInfo['image'] : Template::get_icon_path('session_default.png'); |
||||
} |
||||
|
||||
$userInfo = api_get_user_info($sale['user_id']); |
||||
|
||||
$html = '<h2>' . $sale['product_name'] .'</h2>'; |
||||
$html .= '<div class="row">'; |
||||
$html .= '<div class="col-sm-6 col-md-6">'; |
||||
$html .= '<ul>'; |
||||
$html .= '<li><b>'. $plugin->get_lang('OrderPrice') . ':</b> '. $sale['price'] . '</li>'; |
||||
$html .= '<li><b>'. $plugin->get_lang('CurrencyType') . ':</b> '. $currency['iso_code'] . '</li>'; |
||||
$html .= '<li><b>'. $plugin->get_lang('ProductType') . ':</b> '. $productType . '</li>'; |
||||
$html .= '<li><b>'. $plugin->get_lang('OrderDate') . ':</b> '. api_format_date($sale['date'], DATE_TIME_FORMAT_LONG_24H) . '</li>'; |
||||
$html .= '<li><b>'. $plugin->get_lang('Buyer') . ':</b> '. $userInfo['complete_name'] . '</li>'; |
||||
$html .= '<li><b>'. $plugin->get_lang('PaymentMethods') . ':</b> '. $paymentType . '</li>'; |
||||
$html .= '</ul>'; |
||||
$html .= '</div>'; |
||||
$html .= '<div class="col-sm-6 col-md-6">'; |
||||
$html .= '<img class="thumbnail" src="'. $productImage .'" >'; |
||||
$html .= '</div>'; |
||||
$html .= '</div>'; |
||||
|
||||
echo $html; |
||||
|
||||
break; |
||||
|
||||
case 'stats': |
||||
|
||||
$stats = []; |
||||
$stats['completed_count'] = 0; |
||||
$stats['completed_total_amount'] = 0; |
||||
$stats['pending_count'] = 0; |
||||
$stats['pending_total_amount'] = 0; |
||||
$stats['canceled_count'] = 0; |
||||
$stats['canceled_total_amount'] = 0; |
||||
|
||||
$completedPayouts = $plugin->getPayouts(BuyCoursesPlugin::PAYOUT_STATUS_COMPLETED); |
||||
$pendingPayouts = $plugin->getPayouts(BuyCoursesPlugin::PAYOUT_STATUS_PENDING); |
||||
$canceledPayouts = $plugin->getPayouts(BuyCoursesPlugin::PAYOUT_STATUS_CANCELED); |
||||
$currency = $plugin->getSelectedCurrency(); |
||||
|
||||
foreach ($completedPayouts as $completed) { |
||||
$stats['completed_count'] = count($completedPayouts); |
||||
$stats['completed_total_amount'] += $completed['comission']; |
||||
$stats['completed_total_amount'] = number_format($stats['completed_total_amount'], 2); |
||||
} |
||||
|
||||
foreach ($pendingPayouts as $pending) { |
||||
$stats['pending_count'] = count($pendingPayouts); |
||||
$stats['pending_total_amount'] += $pending['comission']; |
||||
$stats['pending_total_amount'] = number_format($stats['pending_total_amount'], 2); |
||||
} |
||||
|
||||
foreach ($canceledPayouts as $canceled) { |
||||
$stats['canceled_count'] = count($canceledPayouts); |
||||
$stats['canceled_total_amount'] += $canceled['comission']; |
||||
$stats['canceled_total_amount'] = number_format($stats['canceled_total_amount'], 2); |
||||
} |
||||
|
||||
|
||||
$html = '<div class="row">' |
||||
. '<p>' |
||||
. '<ul>' |
||||
. '<li>'. get_plugin_lang("PayoutsTotalCompleted", "BuyCoursesPlugin") .' <b>'. $stats['completed_count'] .'</b> - '. get_plugin_lang("TotalAmount", "BuyCoursesPlugin") .' <b>'. $stats['completed_total_amount'] .' '. $currency['iso_code'] . '</b></li>' |
||||
. '<li>'. get_plugin_lang("PayoutsTotalPending", "BuyCoursesPlugin") .' <b>'. $stats['pending_count'] .'</b> - '. get_plugin_lang("TotalAmount", "BuyCoursesPlugin") .' <b>'. $stats['pending_total_amount'] .' '. $currency['iso_code'] . '</b></li>' |
||||
. '<li>'. get_plugin_lang("PayoutsTotalCanceled", "BuyCoursesPlugin") .' <b>'. $stats['canceled_count'] .'</b> - '. get_plugin_lang("TotalAmount", "BuyCoursesPlugin") .' <b>'. $stats['canceled_total_amount'] .' '. $currency['iso_code'] . '</b></li>' |
||||
. '</ul>' |
||||
. '</p>'; |
||||
$html .= '</div>'; |
||||
echo $html; |
||||
|
||||
break; |
||||
|
||||
case 'processPayout': |
||||
if (api_is_anonymous()) { |
||||
break; |
||||
} |
||||
|
||||
$html = ''; |
||||
$allPays = []; |
||||
$totalAccounts = 0; |
||||
$totalPayout = 0; |
||||
|
||||
$payouts = isset($_POST['payouts']) ? $_POST['payouts'] : ''; |
||||
|
||||
if (!$payouts) { |
||||
|
||||
echo Display::return_message(get_plugin_lang("SelectOptionToProceed", "BuyCoursesPlugin"), 'error', false); |
||||
|
||||
break; |
||||
} |
||||
|
||||
foreach($payouts as $index => $id) { |
||||
$allPays[] = $plugin->getPayouts(BuyCoursesPlugin::PAYOUT_STATUS_PENDING, $id); |
||||
} |
||||
|
||||
foreach($allPays as $payout) { |
||||
$totalPayout += number_format($payout['comission'], 2); |
||||
$totalAccounts++; |
||||
} |
||||
|
||||
$currentCurrency = $plugin->getSelectedCurrency(); |
||||
|
||||
$isoCode = $currentCurrency['iso_code']; |
||||
|
||||
$html .= '<p>'. get_plugin_lang("VerifyTotalAmountToProceedPayout", "BuyCoursesPlugin") .'</p>'; |
||||
$html .= '' |
||||
. '<p>' |
||||
. '<ul>' |
||||
. '<li>'. get_plugin_lang("TotalAcounts", "BuyCoursesPlugin") .' <b>'. $totalAccounts .'</b></li>' |
||||
. '<li>'. get_plugin_lang("TotalPayout", "BuyCoursesPlugin") .' <b>'. $isoCode .' '. $totalPayout .'</b></li>' |
||||
. '</ul>' |
||||
. '</p>'; |
||||
$html .= '<p>'. get_plugin_lang("CautionThisProcessCantBeCanceled", "BuyCoursesPlugin") .'</p>'; |
||||
$html .= '</br></br>'; |
||||
$html .= '<div id="spinner" class="text-center"></div>'; |
||||
|
||||
echo $html; |
||||
break; |
||||
|
||||
case 'proceedPayout': |
||||
if (api_is_anonymous()) { |
||||
break; |
||||
} |
||||
|
||||
$paypalParams = $plugin->getPaypalParams(); |
||||
|
||||
$pruebas = $paypalParams['sandbox'] == 1; |
||||
$paypalUsername = $paypalParams['username']; |
||||
$paypalPassword = $paypalParams['password']; |
||||
$paypalSignature = $paypalParams['signature']; |
||||
|
||||
require_once("paypalfunctions.php"); |
||||
|
||||
$allPayouts = []; |
||||
$totalAccounts = 0; |
||||
$totalPayout = 0; |
||||
|
||||
$payouts = isset($_POST['payouts']) ? $_POST['payouts'] : ''; |
||||
|
||||
if (!$payouts) { |
||||
|
||||
echo Display::return_message(get_plugin_lang("SelectOptionToProceed", "BuyCoursesPlugin"), 'error', false); |
||||
|
||||
break; |
||||
} |
||||
|
||||
foreach($payouts as $index => $id) { |
||||
$allPayouts[] = $plugin->getPayouts(BuyCoursesPlugin::PAYOUT_STATUS_PENDING, $id); |
||||
} |
||||
|
||||
$currentCurrency = $plugin->getSelectedCurrency(); |
||||
|
||||
$isoCode = $currentCurrency['iso_code']; |
||||
|
||||
|
||||
$result = MassPayment($allPayouts, $isoCode); |
||||
|
||||
if($result['ACK'] === 'Success') { |
||||
foreach($allPayouts as $payout) { |
||||
$plugin->setStatusPayouts($payout['id'], BuyCoursesPlugin::PAYOUT_STATUS_COMPLETED); |
||||
} |
||||
|
||||
echo Display::return_message(get_plugin_lang("PayoutSuccess", "BuyCoursesPlugin"), 'success', false); |
||||
|
||||
} else { |
||||
|
||||
echo Display::return_message('<b>'.$result['L_SEVERITYCODE0'].' '.$result['L_ERRORCODE0'].'</b> - '.$result['L_SHORTMESSAGE0'].'</br><ul><li>'. $result['L_LONGMESSAGE0'].'</li></ul>', 'error', false); |
||||
|
||||
} |
||||
|
||||
break; |
||||
|
||||
case 'cancelPayout': |
||||
if (api_is_anonymous()) { |
||||
break; |
||||
} |
||||
|
||||
$payoutId = isset($_POST['id']) ? $_POST['id'] : ''; |
||||
|
||||
$plugin->setStatusPayouts($payoutId, BuyCoursesPlugin::PAYOUT_STATUS_CANCELED); |
||||
|
||||
echo ''; |
||||
|
||||
break; |
||||
} |
||||
exit; |
@ -0,0 +1,57 @@ |
||||
<?php |
||||
/** |
||||
* User Panel |
||||
* @package chamilo.plugin.buycourses |
||||
*/ |
||||
/** |
||||
* Initialization |
||||
*/ |
||||
|
||||
$cidReset = true; |
||||
|
||||
require_once '../../../main/inc/global.inc.php'; |
||||
|
||||
$plugin = BuyCoursesPlugin::create(); |
||||
$includeSessions = $plugin->get('include_sessions') === 'true'; |
||||
|
||||
$userInfo = api_get_user_info(); |
||||
|
||||
$payouts = $plugin->getPayouts(BuyCoursesPlugin::PAYOUT_STATUS_COMPLETED, false, $userInfo['id']); |
||||
|
||||
$payoutList = []; |
||||
|
||||
foreach ($payouts as $payout) { |
||||
$payoutList[] = [ |
||||
'id' => $payout['id'], |
||||
'sale_id' => $payout['sale_id'], |
||||
'reference' => $payout['sale_reference'], |
||||
'date' => api_format_date($payout['date'], DATE_TIME_FORMAT_LONG_24H), |
||||
'payout_date' => ($payout['payout_date'] === '0000-00-00 00:00:00') ? '-' : api_format_date($payout['payout_date'], DATE_TIME_FORMAT_LONG_24H), |
||||
'currency' => $payout['iso_code'], |
||||
'price' => $payout['item_price'], |
||||
'comission' => $payout['comission'], |
||||
'paypal_account' => $payout['paypal_account'], |
||||
'status' => $payout['status'] |
||||
]; |
||||
} |
||||
|
||||
$toolbar = Display::toolbarButton( |
||||
$plugin->get_lang('CourseListOnSale'), |
||||
'course_catalog.php', |
||||
'search-plus', |
||||
'primary', |
||||
['title' => $plugin->get_lang('CourseListOnSale')] |
||||
); |
||||
|
||||
$templateName = get_lang('TabsDashboard'); |
||||
$tpl = new Template($templateName); |
||||
$tpl->assign('showing_courses', true); |
||||
$tpl->assign('sessions_are_included', $includeSessions); |
||||
$tpl->assign('payout_list', $payoutList); |
||||
|
||||
$content = $tpl->fetch('buycourses/view/payout_panel.tpl'); |
||||
|
||||
$tpl->assign('actions', $toolbar); |
||||
$tpl->assign('header', $templateName); |
||||
$tpl->assign('content', $content); |
||||
$tpl->display_one_col_template(); |
@ -0,0 +1,90 @@ |
||||
<?php |
||||
|
||||
/* For license terms, see /license.txt */ |
||||
/** |
||||
* List of pending payments of the Buy Courses plugin |
||||
* @package chamilo.plugin.buycourses |
||||
*/ |
||||
//Initialization |
||||
$cidReset = true; |
||||
|
||||
require_once '../../../main/inc/global.inc.php'; |
||||
|
||||
$htmlHeadXtra[] = '<link rel="stylesheet" href="../resources/css/style.css" type="text/css">'; |
||||
$htmlHeadXtra[] = '<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/1.0.2/Chart.min.js"></script>'; |
||||
|
||||
api_protect_admin_script(true); |
||||
|
||||
$plugin = BuyCoursesPlugin::create(); |
||||
|
||||
$comissionsEnable = $plugin->get('comissions_enable'); |
||||
$payoutStatuses = $plugin->getPayoutStatuses(); |
||||
$selectedStatus = isset($_GET['status']) ? $_GET['status'] : BuyCoursesPlugin::SALE_STATUS_COMPLETED; |
||||
|
||||
if ($comissionsEnable !== "true") { |
||||
api_not_allowed(true); |
||||
} |
||||
|
||||
$form = new FormValidator('search', 'get'); |
||||
|
||||
if ($form->validate()) { |
||||
$selectedStatus = $form->getSubmitValue('status'); |
||||
|
||||
if ($selectedStatus === false) { |
||||
$selectedStatus = BuyCoursesPlugin::PAYOUT_STATUS_PENDING; |
||||
} |
||||
} |
||||
|
||||
$form->addSelect('status', $plugin->get_lang('PayoutStatus'), $payoutStatuses); |
||||
$form->addButtonFilter(get_lang('Search')); |
||||
$form->setDefaults([ |
||||
'status' => $selectedStatus |
||||
]); |
||||
|
||||
switch ($selectedStatus) { |
||||
case '2': |
||||
$payouts = $plugin->getPayouts($selectedStatus); |
||||
|
||||
break; |
||||
case '1': |
||||
$payouts = $plugin->getPayouts($selectedStatus); |
||||
|
||||
break; |
||||
case '0': |
||||
//no break |
||||
default: |
||||
$payouts = $plugin->getPayouts(); |
||||
|
||||
break; |
||||
} |
||||
|
||||
$payoutList = []; |
||||
|
||||
foreach ($payouts as $payout) { |
||||
$payoutList[] = [ |
||||
'id' => $payout['id'], |
||||
'sale_id' => $payout['sale_id'], |
||||
'reference' => $payout['sale_reference'], |
||||
'date' => api_format_date($payout['date'], DATE_TIME_FORMAT_LONG_24H), |
||||
'payout_date' => ($payout['payout_date'] === '0000-00-00 00:00:00') ? '-' : api_format_date($payout['payout_date'], DATE_TIME_FORMAT_LONG_24H), |
||||
'currency' => $payout['iso_code'], |
||||
'price' => $payout['item_price'], |
||||
'comission' => $payout['comission'], |
||||
'paypal_account' => $payout['paypal_account'], |
||||
'status' => $payout['status'] |
||||
]; |
||||
} |
||||
|
||||
$templateName = $plugin->get_lang('PayoutReport'); |
||||
|
||||
$template = new Template($templateName); |
||||
|
||||
$template->assign('form', $form->returnForm()); |
||||
$template->assign('payout_list', $payoutList); |
||||
$template->assign('selected_status', $selectedStatus); |
||||
|
||||
$content = $template->fetch('buycourses/view/payout_report.tpl'); |
||||
|
||||
$template->assign('header', $templateName); |
||||
$template->assign('content', $content); |
||||
$template->display_one_col_template(); |
@ -0,0 +1,55 @@ |
||||
<?php |
||||
|
||||
/* For license terms, see /license.txt */ |
||||
/** |
||||
* List page for Paypal Payout for the Buy Courses plugin |
||||
* @package chamilo.plugin.buycourses |
||||
*/ |
||||
/** |
||||
* Initialization |
||||
*/ |
||||
|
||||
$cidReset = true; |
||||
|
||||
require_once '../../../main/inc/global.inc.php'; |
||||
|
||||
$htmlHeadXtra[] = '<link rel="stylesheet" href="../resources/css/style.css" type="text/css">'; |
||||
|
||||
api_protect_admin_script(true); |
||||
|
||||
$plugin = BuyCoursesPlugin::create(); |
||||
|
||||
$paypalEnable = $plugin->get('paypal_enable'); |
||||
$comissionsEnable = $plugin->get('comissions_enable'); |
||||
|
||||
if ($paypalEnable !== "true" && $comissionsEnable !== "true") { |
||||
api_not_allowed(true); |
||||
} |
||||
|
||||
$payouts = $plugin->getPayouts(); |
||||
|
||||
$payoutList = []; |
||||
|
||||
foreach ($payouts as $payout) { |
||||
$payoutList[] = [ |
||||
'id' => $payout['id'], |
||||
'reference' => $payout['sale_reference'], |
||||
'date' => api_format_date($payout['date'], DATE_TIME_FORMAT_LONG_24H), |
||||
'currency' => $payout['iso_code'], |
||||
'price' => $payout['item_price'], |
||||
'comission' => $payout['comission'], |
||||
'paypal_account' => $payout['paypal_account'] |
||||
]; |
||||
} |
||||
|
||||
$templateName = $plugin->get_lang('PaypalPayoutComissions'); |
||||
|
||||
$template = new Template($templateName); |
||||
|
||||
$template->assign('payout_list', $payoutList); |
||||
|
||||
$content = $template->fetch('buycourses/view/paypal_payout.tpl'); |
||||
|
||||
$template->assign('header', $templateName); |
||||
$template->assign('content', $content); |
||||
$template->display_one_col_template(); |
@ -0,0 +1,61 @@ |
||||
<?php |
||||
/** |
||||
* User Panel |
||||
* @package chamilo.plugin.buycourses |
||||
*/ |
||||
/** |
||||
* Initialization |
||||
*/ |
||||
|
||||
$cidReset = true; |
||||
|
||||
require_once '../../../main/inc/global.inc.php'; |
||||
|
||||
$plugin = BuyCoursesPlugin::create(); |
||||
$includeSessions = $plugin->get('include_sessions') === 'true'; |
||||
|
||||
$userInfo = api_get_user_info(); |
||||
|
||||
$productTypes = $plugin->getProductTypes(); |
||||
$saleStatuses = $plugin->getSaleStatuses(); |
||||
$paymentTypes = $plugin->getPaymentTypes(); |
||||
|
||||
$sales = $plugin->getSaleListByUserId($userInfo['id']); |
||||
|
||||
$saleList = []; |
||||
|
||||
foreach ($sales as $sale) { |
||||
if ($sale['product_type'] == 2) { |
||||
$saleList[] = [ |
||||
'id' => $sale['id'], |
||||
'reference' => $sale['reference'], |
||||
'date' => api_format_date($sale['date'], DATE_TIME_FORMAT_LONG_24H), |
||||
'currency' => $sale['iso_code'], |
||||
'price' => $sale['price'], |
||||
'product_name' => $sale['product_name'], |
||||
'product_type' => $productTypes[$sale['product_type']], |
||||
'payment_type' => $paymentTypes[$sale['payment_type']] |
||||
]; |
||||
} |
||||
} |
||||
|
||||
$toolbar = Display::toolbarButton( |
||||
$plugin->get_lang('CourseListOnSale'), |
||||
'course_catalog.php', |
||||
'search-plus', |
||||
'primary', |
||||
['title' => $plugin->get_lang('CourseListOnSale')] |
||||
); |
||||
|
||||
$templateName = get_lang('TabsDashboard'); |
||||
$tpl = new Template($templateName); |
||||
$tpl->assign('showing_courses', true); |
||||
$tpl->assign('sessions_are_included', $includeSessions); |
||||
$tpl->assign('sale_list', $saleList); |
||||
|
||||
$content = $tpl->fetch('buycourses/view/session_panel.tpl'); |
||||
|
||||
$tpl->assign('actions', $toolbar); |
||||
$tpl->assign('header', $templateName); |
||||
$tpl->assign('content', $content); |
||||
$tpl->display_one_col_template(); |
@ -0,0 +1,43 @@ |
||||
<link rel="stylesheet" type="text/css" href="../resources/css/style.css"/> |
||||
|
||||
<div id="buy-courses-tabs"> |
||||
|
||||
<ul class="nav nav-tabs buy-courses-tabs" role="tablist"> |
||||
<li id="buy-courses-tab" class="active" 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 %} |
||||
<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>{{ 'Course'|get_lang }}</th> |
||||
<th class="text-center">{{ 'PaymentMethod'|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> |
||||
</tr> |
||||
</thead> |
||||
<tbody> |
||||
{% for sale in sale_list %} |
||||
<tr> |
||||
<td>{{ sale.product_name }}</td> |
||||
<td class="text-center">{{ sale.payment_type }}</td> |
||||
<td class="text-right">{{ sale.currency ~ ' ' ~ sale.price }}</td> |
||||
<td class="text-center">{{ sale.date }}</td> |
||||
<td class="text-center">{{ sale.reference }}</td> |
||||
</tr> |
||||
{% endfor %} |
||||
</tbody> |
||||
</table> |
||||
|
||||
|
||||
</div> |
@ -0,0 +1,41 @@ |
||||
<link rel="stylesheet" type="text/css" href="../resources/css/style.css"/> |
||||
|
||||
<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 %} |
||||
<li id="buy-courses-tab" class="active" 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 class="text-center">{{ 'OrderReference'| get_plugin_lang('BuyCoursesPlugin') }}</th> |
||||
<th class="text-center">{{ 'PayoutDate'| get_plugin_lang('BuyCoursesPlugin') }}</th> |
||||
<th class="text-right">{{ 'Comission'| get_plugin_lang('BuyCoursesPlugin') }}</th> |
||||
<th class="text-right">{{ 'PayPalAccount'| get_plugin_lang('BuyCoursesPlugin') }}</th> |
||||
</tr> |
||||
</thead> |
||||
<tbody> |
||||
{% for payout in payout_list %} |
||||
<tr> |
||||
<td class="text-center" style="vertical-align:middle"><a id="{{ payout.sale_id }}" class="saleInfo" data-toggle="modal" data-target="#saleInfo" href="#">{{ payout.reference }}</a></td> |
||||
<td class="text-center" style="vertical-align:middle">{{ payout.payout_date }}</td> |
||||
<td class="text-right" style="vertical-align:middle">{{ payout.currency ~ ' ' ~ payout.comission }}</td> |
||||
<td class="text-right" style="vertical-align:middle">{{ payout.paypal_account }}</td> |
||||
</tr> |
||||
{% endfor %} |
||||
</tbody> |
||||
</table> |
||||
|
||||
|
||||
</div> |
@ -0,0 +1,88 @@ |
||||
{{ form }} |
||||
<div class="table-responsive"> |
||||
<table class="table table-striped table-hover"> |
||||
<thead> |
||||
<tr> |
||||
<th class="text-center">{{ 'OrderReference'| get_plugin_lang('BuyCoursesPlugin') }}</th> |
||||
<th class="text-center">{{ 'PayoutDate'| get_plugin_lang('BuyCoursesPlugin') }}</th> |
||||
<th class="text-right">{{ 'Comission'| get_plugin_lang('BuyCoursesPlugin') }}</th> |
||||
<th class="text-right">{{ 'PayPalAccount'| get_plugin_lang('BuyCoursesPlugin') }}</th> |
||||
</tr> |
||||
</thead> |
||||
<tbody> |
||||
{% for payout in payout_list %} |
||||
<tr> |
||||
<td class="text-center" style="vertical-align:middle"><a id="{{ payout.sale_id }}" class="saleInfo" data-toggle="modal" data-target="#saleInfo" href="#">{{ payout.reference }}</a></td> |
||||
<td class="text-center" style="vertical-align:middle">{{ payout.payout_date }}</td> |
||||
<td class="text-right" style="vertical-align:middle">{{ payout.currency ~ ' ' ~ payout.comission }}</td> |
||||
<td class="text-right" style="vertical-align:middle">{{ payout.paypal_account }}</td> |
||||
</tr> |
||||
{% endfor %} |
||||
</tbody> |
||||
</table> |
||||
<div id="saleInfo" class="modal fade" role="dialog"> |
||||
<div class="modal-dialog modal-lg"> |
||||
<div class="modal-content"> |
||||
<div class="modal-header"> |
||||
<h4 class="modal-title">{{ 'SaleInfo'| get_plugin_lang('BuyCoursesPlugin') }}</h4> |
||||
</div> |
||||
<div class="modal-body" id="contentSale"> |
||||
|
||||
</div> |
||||
<div class="modal-footer"> |
||||
<button type="button" class="btn btn-default" data-dismiss="modal">{{ 'Close' | get_lang }}</button> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
|
||||
<div id="reportStats" class="modal fade" role="dialog"> |
||||
<div class="modal-dialog"> |
||||
<div class="modal-content"> |
||||
<div class="modal-header"> |
||||
<h4 class="modal-title">{{ 'Stats'| get_plugin_lang('BuyCoursesPlugin') }}</h4> |
||||
</div> |
||||
<div class="modal-body" id="contentStats"> |
||||
|
||||
</div> |
||||
<div class="modal-footer"> |
||||
<button type="button" class="btn btn-default" data-dismiss="modal">{{ 'Close' | get_lang }}</button> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
|
||||
<div> |
||||
<button id="stats" type="button" class="btn btn-primary fa fa-line-chart" data-toggle="modal" data-target="#reportStats"> {{ 'Stats'|get_plugin_lang('BuyCoursesPlugin') }}</button> |
||||
</div> |
||||
|
||||
<script> |
||||
$(document).ready(function() { |
||||
|
||||
$(".saleInfo").click(function() { |
||||
var id = this.id; |
||||
$.ajax({ |
||||
data: 'id='+id, |
||||
url: '{{ _p.web_plugin ~ 'buycourses/src/buycourses.ajax.php?' ~ { 'a': 'saleInfo' } | url_encode() }}', |
||||
type: 'POST', |
||||
success: function(response) { |
||||
$("#contentSale").html(response); |
||||
} |
||||
}); |
||||
}); |
||||
|
||||
$("#stats").click(function() { |
||||
var id = this.id; |
||||
$.ajax({ |
||||
data: 'id='+id, |
||||
url: '{{ _p.web_plugin ~ 'buycourses/src/buycourses.ajax.php?' ~ { 'a': 'stats' } | url_encode() }}', |
||||
type: 'POST', |
||||
success: function(response) { |
||||
$("#contentStats").html(response); |
||||
} |
||||
}); |
||||
}); |
||||
|
||||
}); |
||||
</script> |
@ -0,0 +1,121 @@ |
||||
<div class="table-responsive"> |
||||
<table class="table table-striped table-hover"> |
||||
<thead> |
||||
<tr> |
||||
<th class="text-center"><input type="checkbox" id="checkAll"></th> |
||||
<th class="text-center">{{ 'OrderReference'| get_plugin_lang('BuyCoursesPlugin') }}</th> |
||||
<th class="text-center">{{ 'OrderDate'| get_plugin_lang('BuyCoursesPlugin') }}</th> |
||||
<th class="text-right">{{ 'Comission'| get_plugin_lang('BuyCoursesPlugin') }}</th> |
||||
<th class="text-right">{{ 'PayPalAccount'| get_plugin_lang('BuyCoursesPlugin') }}</th> |
||||
<th class="text-right">{{ 'Options'| get_lang }}</th> |
||||
</tr> |
||||
</thead> |
||||
<tbody> |
||||
{% for payout in payout_list %} |
||||
<tr style="{{ payout.paypal_account ? '' : 'color: red;' }}"> |
||||
<td class="text-center" style="vertical-align:middle">{% if payout.paypal_account %} <input id="{{ payout.id }}" type="checkbox" name="data[]" value="{{ payout.comission }}"> {% endif %}</td> |
||||
<td class="text-center" style="vertical-align:middle">{{ payout.reference }}</td> |
||||
<td class="text-center" style="vertical-align:middle">{{ payout.date }}</td> |
||||
<td class="text-right" style="vertical-align:middle">{{ payout.currency ~ ' ' ~ payout.comission }}</td> |
||||
{% if payout.paypal_account %} |
||||
<td class="text-right" style="vertical-align:middle">{{ payout.paypal_account }}</td> |
||||
{% else %} |
||||
<td class="text-right" style="vertical-align:middle">{{ 'NoPayPalAccountDetected'| get_plugin_lang('BuyCoursesPlugin') }}</td> |
||||
{% endif %} |
||||
<td class="text-right" style="vertical-align:middle"><button id="{{ payout.id }}" type="button" class="btn btn-danger fa fa-ban cancelPayout"> {{ 'CancelPayout'| get_plugin_lang('BuyCoursesPlugin') }}</button></td> |
||||
</tr> |
||||
{% endfor %} |
||||
</tbody> |
||||
</table> |
||||
|
||||
<div id="startPayout" class="modal fade" role="dialog"> |
||||
<div class="modal-dialog modal-lg"> |
||||
<div class="modal-content"> |
||||
<div class="modal-header"> |
||||
<h4 class="modal-title">{{ 'PaypalPayoutComissions'|get_plugin_lang('BuyCoursesPlugin') }}</h4> |
||||
</div> |
||||
<div class="modal-body" id="content"> |
||||
|
||||
</div> |
||||
<div class="modal-footer"> |
||||
<button id="proceedPayout" type="button" class="btn btn-success fa fa-paypal"> {{ 'ProceedPayout' | get_plugin_lang('BuyCoursesPlugin') }}</button> |
||||
<button id="cancelPayout" type="button" class="btn btn-danger" data-dismiss="modal">{{ 'Cancel' | get_lang }}</button> |
||||
<button id="responseButton" type="button" class="btn btn-primary">{{ 'Confirm' | get_lang }}</button> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
<div> |
||||
<button id="continuePayout" type="button" class="btn btn-primary fa fa-caret-square-o-right" data-toggle="modal" data-target="#startPayout" data-backdrop="static" data-keyboard="false"> {{ 'ContinuePayout'|get_plugin_lang('BuyCoursesPlugin') }}</button> |
||||
</div> |
||||
|
||||
<script> |
||||
$(document).ready(function() { |
||||
|
||||
$("#responseButton").hide(); |
||||
|
||||
$("#checkAll").click(function() { |
||||
$(':checkbox').prop('checked', this.checked); |
||||
}); |
||||
|
||||
$('#continuePayout').click(function() { |
||||
|
||||
var val = []; |
||||
|
||||
$(':checkbox:checked').not('#checkAll').each(function(i) { |
||||
val[i] = $(this).attr("id"); |
||||
}); |
||||
|
||||
$.ajax({ |
||||
data: { payouts : val }, |
||||
url: '{{ _p.web_plugin ~ 'buycourses/src/buycourses.ajax.php?' ~ { 'a': 'processPayout' } | url_encode() }}', |
||||
type: 'POST', |
||||
success: function(response) { |
||||
$("#content").html(response); |
||||
(jQuery.isEmptyObject(val)) ? $('#proceedPayout').prop( "disabled", true ) : $('#proceedPayout').prop( "disabled", false ); |
||||
} |
||||
}); |
||||
}); |
||||
|
||||
$('#proceedPayout').click(function() { |
||||
|
||||
var val = []; |
||||
|
||||
$(':checkbox:checked').not('#checkAll').each(function(i) { |
||||
val[i] = $(this).attr("id"); |
||||
}); |
||||
|
||||
$.ajax({ |
||||
data: { payouts : val }, |
||||
url: '{{ _p.web_plugin ~ 'buycourses/src/buycourses.ajax.php?' ~ { 'a': 'proceedPayout' } | url_encode() }}', |
||||
type: 'POST', |
||||
beforeSend: function() { |
||||
$("#proceedPayout").hide(); |
||||
$("#cancelPayout").hide(); |
||||
$("#spinner").html('</br></br><div class="wobblebar-loader"></div><p> {{ 'ProcessingPayoutsDontCloseThisWindow' | get_plugin_lang('BuyCoursesPlugin') }} </p>'); |
||||
}, |
||||
success: function(response) { |
||||
$("#content").html(response); |
||||
$("#responseButton").show(); |
||||
} |
||||
}); |
||||
}); |
||||
|
||||
$(".cancelPayout").click(function() { |
||||
var id = this.id; |
||||
$.ajax({ |
||||
data: 'id='+id, |
||||
url: '{{ _p.web_plugin ~ 'buycourses/src/buycourses.ajax.php?' ~ { 'a': 'cancelPayout' } | url_encode() }}', |
||||
type: 'POST', |
||||
success: function() { |
||||
window.location.reload(); |
||||
} |
||||
}); |
||||
}); |
||||
|
||||
$('#responseButton').click(function() { |
||||
window.location.reload(); |
||||
}); |
||||
}); |
||||
</script> |
@ -0,0 +1,43 @@ |
||||
<link rel="stylesheet" type="text/css" href="../resources/css/style.css"/> |
||||
|
||||
<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="active" role="presentation"> |
||||
<a href="session_panel.php" aria-controls="buy-sessions" role="tab">{{ 'MySessions'| get_lang }}</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>{{ 'Session'|get_lang }}</th> |
||||
<th class="text-center">{{ 'PaymentMethod'|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> |
||||
</tr> |
||||
</thead> |
||||
<tbody> |
||||
{% for sale in sale_list %} |
||||
<tr> |
||||
<td>{{ sale.product_name }}</td> |
||||
<td class="text-center">{{ sale.payment_type }}</td> |
||||
<td class="text-right">{{ sale.currency ~ ' ' ~ sale.price }}</td> |
||||
<td class="text-center">{{ sale.date }}</td> |
||||
<td class="text-center">{{ sale.reference }}</td> |
||||
</tr> |
||||
{% endfor %} |
||||
</tbody> |
||||
</table> |
||||
|
||||
|
||||
</div> |
Loading…
Reference in new issue