new sales report filters #3021

pull/3023/head
Alex Aragón 6 years ago
parent a9c54a8d80
commit 5b0288f3cc
  1. 2
      plugin/buycourses/lang/brazilian.php
  2. 1
      plugin/buycourses/lang/english.php
  3. 3
      plugin/buycourses/lang/french.php
  4. 1
      plugin/buycourses/lang/spanish.php
  5. 13
      plugin/buycourses/resources/css/style.css
  6. 74
      plugin/buycourses/src/buy_course_plugin.class.php
  7. 28
      plugin/buycourses/src/sales_report.php
  8. 56
      plugin/buycourses/view/sales_report.tpl

@ -8,7 +8,6 @@ $strings['paypal_enable'] = "Ativar PayPal";
$strings['transfer_enable'] = "Permitir transferência bancária"; $strings['transfer_enable'] = "Permitir transferência bancária";
$strings['unregistered_users_enable'] = "Permitir que usuários anônimos"; $strings['unregistered_users_enable'] = "Permitir que usuários anônimos";
$strings['Free'] = "GRÁTIS"; $strings['Free'] = "GRÁTIS";
$strings['banktransfer'] = "Transferência Bancária"; $strings['banktransfer'] = "Transferência Bancária";
$strings['SaleStatusPending'] = "Venda pendente"; $strings['SaleStatusPending'] = "Venda pendente";
$strings['SaleStatusCanceled'] = "Venda cancelada"; $strings['SaleStatusCanceled'] = "Venda cancelada";
@ -91,6 +90,7 @@ $strings['AvailableCourse'] = "Campo disponível";
$strings['ShowOnCourseCatalog'] = "Mostrar no catálogo de cursos"; $strings['ShowOnCourseCatalog'] = "Mostrar no catálogo de cursos";
$strings['ByStatus'] = "Por estado"; $strings['ByStatus'] = "Por estado";
$strings['ByUser'] = "Por usuário"; $strings['ByUser'] = "Por usuário";
$strings['ByEmail'] = "Por email";
$strings['PaymentMethod'] = "Método de pagamento"; $strings['PaymentMethod'] = "Método de pagamento";
$strings['SWIFT'] = "Código SWIFT"; $strings['SWIFT'] = "Código SWIFT";
$strings['SWIFT_help'] = "Formato padrão de Códigos de Identificação Bancária (BIC) e serve como um identificador exclusivo de um banco ou instituição financeira"; $strings['SWIFT_help'] = "Formato padrão de Códigos de Identificação Bancária (BIC) e serve como um identificador exclusivo de um banco ou instituição financeira";

@ -133,6 +133,7 @@ $strings['AvailableCourse'] = "Available course";
$strings['ShowOnCourseCatalog'] = "Show on course catalog"; $strings['ShowOnCourseCatalog'] = "Show on course catalog";
$strings['ByStatus'] = "By status"; $strings['ByStatus'] = "By status";
$strings['ByUser'] = "By user"; $strings['ByUser'] = "By user";
$strings['ByEmail'] = "By email";
$strings['PaymentMethod'] = "Payment method"; $strings['PaymentMethod'] = "Payment method";
$strings['SWIFT'] = "SWIFT code"; $strings['SWIFT'] = "SWIFT code";
$strings['SWIFT_help'] = "Standard format of Bank Identifier Codes (BIC) and serves as a unique identifier for a bank or financial institution"; $strings['SWIFT_help'] = "Standard format of Bank Identifier Codes (BIC) and serves as a unique identifier for a bank or financial institution";

@ -9,7 +9,6 @@ $strings['commissions_enable'] = "Activer commissions";
$strings['transfer_enable'] = "Activer les transferts bancaires"; $strings['transfer_enable'] = "Activer les transferts bancaires";
$strings['unregistered_users_enable'] = "Permettre l'accès aux utilisateurs non enregistrés sur la plateforme"; $strings['unregistered_users_enable'] = "Permettre l'accès aux utilisateurs non enregistrés sur la plateforme";
$strings['Free'] = "GRATUIT"; $strings['Free'] = "GRATUIT";
$strings['PaypalPayoutCommissions'] = "Commissions PayPal Payouts"; $strings['PaypalPayoutCommissions'] = "Commissions PayPal Payouts";
$strings['MyPayouts'] = "Mes paiements"; $strings['MyPayouts'] = "Mes paiements";
$strings['Commission'] = "Commission"; $strings['Commission'] = "Commission";
@ -130,6 +129,7 @@ $strings['AvailableCourse'] = "Cours disponibles";
$strings['ShowOnCourseCatalog'] = "Afficher dans le catalogue de cours"; $strings['ShowOnCourseCatalog'] = "Afficher dans le catalogue de cours";
$strings['ByStatus'] = "Par statut"; $strings['ByStatus'] = "Par statut";
$strings['ByUser'] = "Par utilisateur"; $strings['ByUser'] = "Par utilisateur";
$strings['ByEmail'] = "Par email";
$strings['PaymentMethod'] = "Méthodes de paiement"; $strings['PaymentMethod'] = "Méthodes de paiement";
$strings['SWIFT'] = "Code SWIFT"; $strings['SWIFT'] = "Code SWIFT";
$strings['SWIFT_help'] = "Format standard des codes d'identification de banque (BIC) et sert un identifiant unique pour une banque ou une institution financière."; $strings['SWIFT_help'] = "Format standard des codes d'identification de banque (BIC) et sert un identifiant unique pour une banque ou une institution financière.";
@ -140,7 +140,6 @@ $strings['public_main_menu_tab'] = "Montrer l'onglet dans le menu principal aux
$strings['culqi_enable'] = "Activé culqi"; $strings['culqi_enable'] = "Activé culqi";
$strings['include_services'] = "Inclure les services"; $strings['include_services'] = "Inclure les services";
$strings['hide_free_text'] = "Cacher le texte 'Free' ou 'Gratuit'"; $strings['hide_free_text'] = "Cacher le texte 'Free' ou 'Gratuit'";
$strings['Services'] = "Services"; $strings['Services'] = "Services";
$strings['ServiceName'] = "Nom du service"; $strings['ServiceName'] = "Nom du service";
$strings['AppliesTo'] = "S'applique à"; $strings['AppliesTo'] = "S'applique à";

@ -133,6 +133,7 @@ $strings['AvailableCourse'] = "Curso disponible";
$strings['ShowOnCourseCatalog'] = "Mostrar en el catálogo de cursos"; $strings['ShowOnCourseCatalog'] = "Mostrar en el catálogo de cursos";
$strings['ByStatus'] = "Por estado"; $strings['ByStatus'] = "Por estado";
$strings['ByUser'] = "Por usuario"; $strings['ByUser'] = "Por usuario";
$strings['ByEmail'] = "Por email";
$strings['PaymentMethod'] = "Método de pago"; $strings['PaymentMethod'] = "Método de pago";
$strings['SWIFT'] = "Código SWIFT"; $strings['SWIFT'] = "Código SWIFT";
$strings['SWIFT_help'] = "Formato estándar de los Códigos de Identificación Bancaria (BIC) que sirve como identificador único para un banco o institución financiera."; $strings['SWIFT_help'] = "Formato estándar de los Códigos de Identificación Bancaria (BIC) que sirve como identificador único para un banco o institución financiera.";

@ -86,7 +86,18 @@
background-color: #e8f2f8; background-color: #e8f2f8;
border-color: #bce8f1; border-color: #bce8f1;
} }
tr.sale-row {
font-size: 12px;
}
tr.sale-columns {
font-size: 10px;
text-transform: uppercase;
background-color: #e6e6e6;
}
tr.sale-columns th{
vertical-align: middle !important;
text-align: center;
}
@-moz-keyframes wobblebar-loader { @-moz-keyframes wobblebar-loader {
0% { 0% {
left: 4px; left: 4px;

@ -1269,7 +1269,7 @@ class BuyCoursesPlugin extends Plugin
"; ";
return Database::select( return Database::select(
['c.iso_code', 'u.firstname', 'u.lastname', 's.*'], ['c.iso_code', 'u.firstname', 'u.lastname', 'u.email', 's.*'],
"$saleTable s $innerJoins", "$saleTable s $innerJoins",
[ [
'where' => ['s.status = ?' => (int) $status], 'where' => ['s.status = ?' => (int) $status],
@ -1503,7 +1503,7 @@ class BuyCoursesPlugin extends Plugin
"; ";
return Database::select( return Database::select(
['c.iso_code', 'u.firstname', 'u.lastname', 's.*'], ['c.iso_code', 'u.firstname', 'u.lastname', 'u.email', 's.*'],
"$saleTable s $innerJoins", "$saleTable s $innerJoins",
[ [
'where' => [ 'where' => [
@ -1550,6 +1550,76 @@ class BuyCoursesPlugin extends Plugin
); );
} }
/**
* Get a list of sales by date range.
*
* @param string $dateStart
* @param string $dateEnd
*
* @return array The sale list. Otherwise return false
*/
public function getSaleListByDate($dateStart, $dateEnd)
{
$dateStart = trim($dateStart);
$dateEnd = trim($dateEnd);
if (empty($dateStart)) {
return [];
}
if (empty($dateEnd)) {
return [];
}
$saleTable = Database::get_main_table(self::TABLE_SALE);
$currencyTable = Database::get_main_table(self::TABLE_CURRENCY);
$userTable = Database::get_main_table(TABLE_MAIN_USER);
$innerJoins = "
INNER JOIN $currencyTable c ON s.currency_id = c.id
INNER JOIN $userTable u ON s.user_id = u.id
";
return Database::select(
['c.iso_code', 'u.firstname', 'u.lastname', 'u.email' , 's.*'],
"$saleTable s $innerJoins",
[
'where' => [
's.date BETWEEN ? AND ' => $dateStart,
' ? ' => $dateEnd,
],
'order' => 'id DESC',
]
);
}
/**
* Get a list of sales by the user Email.
*
* @param string $term The search term
*
* @return array The sale list. Otherwise return false
*/
public function getSaleListByEmail($term)
{
$term = trim($term);
if (empty($term)) {
return [];
}
$saleTable = Database::get_main_table(self::TABLE_SALE);
$currencyTable = Database::get_main_table(self::TABLE_CURRENCY);
$userTable = Database::get_main_table(TABLE_MAIN_USER);
$innerJoins = "
INNER JOIN $currencyTable c ON s.currency_id = c.id
INNER JOIN $userTable u ON s.user_id = u.id
";
return Database::select(
['c.iso_code', 'u.firstname', 'u.lastname', 'u.email', 's.*'],
"$saleTable s $innerJoins",
[
'where' => [
'u.email LIKE %?% ' => $term,
],
'order' => 'id DESC',
]
);
}
/** /**
* Convert the course info to array with necessary course data for save item. * Convert the course info to array with necessary course data for save item.
* *

@ -69,7 +69,10 @@ $paymentTypes = $plugin->getPaymentTypes();
$selectedFilterType = '0'; $selectedFilterType = '0';
$selectedStatus = isset($_GET['status']) ? $_GET['status'] : BuyCoursesPlugin::SALE_STATUS_PENDING; $selectedStatus = isset($_GET['status']) ? $_GET['status'] : BuyCoursesPlugin::SALE_STATUS_PENDING;
$selectedSale = isset($_GET['sale']) ? intval($_GET['sale']) : 0; $selectedSale = isset($_GET['sale']) ? intval($_GET['sale']) : 0;
$dateStart = isset($_GET['date_start']) ? $_GET['date_start'] : date('Y-m-d H:i', mktime(0,0,0));
$dateEnd = isset($_GET['date_end']) ? $_GET['date_end'] : date('Y-m-d H:i', mktime(23,59,59));
$searchTerm = ''; $searchTerm = '';
$email = '';
$form = new FormValidator('search', 'get'); $form = new FormValidator('search', 'get');
@ -77,6 +80,9 @@ if ($form->validate()) {
$selectedFilterType = $form->getSubmitValue('filter_type'); $selectedFilterType = $form->getSubmitValue('filter_type');
$selectedStatus = $form->getSubmitValue('status'); $selectedStatus = $form->getSubmitValue('status');
$searchTerm = $form->getSubmitValue('user'); $searchTerm = $form->getSubmitValue('user');
$dateStart = $form->getSubmitValue('date_start');
$dateEnd = $form->getSubmitValue('date_end');
$email = $form->getSubmitValue('email');
if ($selectedStatus === false) { if ($selectedStatus === false) {
$selectedStatus = BuyCoursesPlugin::SALE_STATUS_PENDING; $selectedStatus = BuyCoursesPlugin::SALE_STATUS_PENDING;
@ -90,7 +96,12 @@ if ($form->validate()) {
$form->addRadio( $form->addRadio(
'filter_type', 'filter_type',
get_lang('Filter'), get_lang('Filter'),
[$plugin->get_lang('ByStatus'), $plugin->get_lang('ByUser')] [
$plugin->get_lang('ByStatus'),
$plugin->get_lang('ByUser'),
$plugin->get_lang('ByDate'),
$plugin->get_lang('ByEmail')
]
); );
$form->addHtml('<div id="report-by-status" '.($selectedFilterType !== '0' ? 'style="display:none"' : '').'>'); $form->addHtml('<div id="report-by-status" '.($selectedFilterType !== '0' ? 'style="display:none"' : '').'>');
$form->addSelect('status', $plugin->get_lang('OrderStatus'), $saleStatuses); $form->addSelect('status', $plugin->get_lang('OrderStatus'), $saleStatuses);
@ -98,10 +109,19 @@ $form->addHtml('</div>');
$form->addHtml('<div id="report-by-user" '.($selectedFilterType !== '1' ? 'style="display:none"' : '').'>'); $form->addHtml('<div id="report-by-user" '.($selectedFilterType !== '1' ? 'style="display:none"' : '').'>');
$form->addText('user', get_lang('UserName'), false); $form->addText('user', get_lang('UserName'), false);
$form->addHtml('</div>'); $form->addHtml('</div>');
$form->addHtml('<div id="report-by-date" '.($selectedFilterType !== '2' ? 'style="display:none"' : '').'>');
$form->addDateRangePicker('date', get_lang('Date'), false);
$form->addHtml('</div>');
$form->addHtml('<div id="report-by-email" '.($selectedFilterType !== '3' ? 'style="display:none"' : '').'>');
$form->addText('email', get_lang('Email'), false);
$form->addHtml('</div>');
$form->addButtonFilter(get_lang('Search')); $form->addButtonFilter(get_lang('Search'));
$form->setDefaults([ $form->setDefaults([
'filter_type' => $selectedFilterType, 'filter_type' => $selectedFilterType,
'status' => $selectedStatus, 'status' => $selectedStatus,
'date_start' => $dateStart,
'date_end' => $dateEnd,
'email' => $email
]); ]);
switch ($selectedFilterType) { switch ($selectedFilterType) {
@ -111,6 +131,12 @@ switch ($selectedFilterType) {
case '1': case '1':
$sales = $plugin->getSaleListByUser($searchTerm); $sales = $plugin->getSaleListByUser($searchTerm);
break; break;
case '2':
$sales = $plugin->getSaleListByDate($dateStart, $dateEnd);
break;
case '3':
$sales = $plugin->getSaleListByEmail($email);
break;
} }
foreach ($sales as &$sale) { foreach ($sales as &$sale) {

@ -18,24 +18,25 @@
<div class="table-responsive"> <div class="table-responsive">
<table class="table table-striped table-hover"> <table class="table table-striped table-hover">
<thead> <thead>
<tr> <tr class="sale-columns">
<th class="text-center">{{ 'OrderReference'|get_plugin_lang('BuyCoursesPlugin') }}</th> <th>{{ 'OrderReference'|get_plugin_lang('BuyCoursesPlugin') }}</th>
<th class="text-center">{{ 'OrderStatus'|get_plugin_lang('BuyCoursesPlugin') }}</th> <th>{{ 'OrderStatus'|get_plugin_lang('BuyCoursesPlugin') }}</th>
<th class="text-center">{{ 'OrderDate'|get_plugin_lang('BuyCoursesPlugin') }}</th> <th>{{ 'OrderDate'|get_plugin_lang('BuyCoursesPlugin') }}</th>
<th class="text-center">{{ 'PaymentMethod'|get_plugin_lang('BuyCoursesPlugin') }}</th> <th>{{ 'PaymentMethod'|get_plugin_lang('BuyCoursesPlugin') }}</th>
<th class="text-center">{{ 'Price'|get_plugin_lang('BuyCoursesPlugin') }}</th> <th>{{ 'Price'|get_plugin_lang('BuyCoursesPlugin') }}</th>
<th class="text-center">{{ 'ProductType'|get_plugin_lang('BuyCoursesPlugin') }}</th> <th>{{ 'ProductType'|get_plugin_lang('BuyCoursesPlugin') }}</th>
<th>{{ 'Name'|get_lang }}</th> <th>{{ 'Name'|get_lang }}</th>
<th>{{ 'UserName'|get_lang }}</th> <th>{{ 'UserName'|get_lang }}</th>
<th>{{ 'Email'|get_lang }}</th>
{% if invoicing_enable %} {% if invoicing_enable %}
<th class="text-center">{{ 'Invoice'|get_plugin_lang('BuyCoursesPlugin') }}</th> <th>{{ 'Invoice'|get_plugin_lang('BuyCoursesPlugin') }}</th>
{% endif %} {% endif %}
<th class="text-center">{{ 'Options'|get_lang }}</th> <th width="10%">{{ 'Options'|get_lang }}</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{% for sale in sale_list %} {% for sale in sale_list %}
<tr {{ sale.id == selected_sale ? 'class="warning"' : '' }}> <tr class="sale-row {{ sale.id == selected_sale ? 'warning' : '' }}">
<td class="text-center">{{ sale.reference }}</td> <td class="text-center">{{ sale.reference }}</td>
<td class="text-center"> <td class="text-center">
{% if sale.status == sale_status_canceled %} {% if sale.status == sale_status_canceled %}
@ -52,6 +53,7 @@
<td class="text-center">{{ sale.product_type }}</td> <td class="text-center">{{ sale.product_type }}</td>
<td>{{ sale.product_name }}</td> <td>{{ sale.product_name }}</td>
<td>{{ sale.complete_user_name }}</td> <td>{{ sale.complete_user_name }}</td>
<td>{{ sale.email }}</td>
{% if invoicing_enable %} {% if invoicing_enable %}
<td class="text-center"> <td class="text-center">
{% if sale.invoice == 1 %} {% if sale.invoice == 1 %}
@ -64,14 +66,16 @@
{% endif %} {% endif %}
<td class="text-center"> <td class="text-center">
{% if sale.status == sale_status_pending %} {% if sale.status == sale_status_pending %}
<a href="{{ _p.web_self ~ '?' ~ {'order': sale.id, 'action': 'confirm'}|url_encode() }}" <div class="btn-group btn-group-xs" role="group" aria-label="...">
class="btn btn-success btn-sm"> <a title="{{ 'SubscribeUser'|get_plugin_lang('BuyCoursesPlugin') }}" href="{{ _p.web_self ~ '?' ~ {'order': sale.id, 'action': 'confirm'}|url_encode() }}"
<em class="fa fa-user-plus fa-fw"></em> {{ 'SubscribeUser'|get_plugin_lang('BuyCoursesPlugin') }} class="btn btn-default">
</a> <img src="{{ 'user_subscribe_session.png' | icon(22) }}" width="22" height="22 alt="{{ 'SubscribeUser'|get_plugin_lang('BuyCoursesPlugin') }}">
<a href="{{ _p.web_self ~ '?' ~ {'order': sale.id, 'action': 'cancel'}|url_encode() }}" </a>
class="btn btn-danger btn-sm"> <a title="{{ 'DeleteOrder'|get_plugin_lang('BuyCoursesPlugin') }}" href="{{ _p.web_self ~ '?' ~ {'order': sale.id, 'action': 'cancel'}|url_encode() }}"
<em class="fa fa-times fa-fw"></em> {{ 'DeleteOrder'|get_plugin_lang('BuyCoursesPlugin') }} class="btn btn-default">
</a> <img src="{{ 'delete.png' | icon(22) }}" width="22" height="22 alt="{{ 'DeleteOrder'|get_plugin_lang('BuyCoursesPlugin') }}">
</a>
</div>
{% endif %} {% endif %}
</td> </td>
</tr> </tr>
@ -88,9 +92,23 @@
if (self.val() === '0') { if (self.val() === '0') {
$('#report-by-user').hide(); $('#report-by-user').hide();
$('#report-by-status').show(); $('#report-by-status').show();
} else { $('#report-by-date').hide();
$('#report-by-email').hide();
} else if (self.val() === '1') {
$('#report-by-status').hide(); $('#report-by-status').hide();
$('#report-by-user').show(); $('#report-by-user').show();
$('#report-by-date').hide();
$('#report-by-email').hide();
} else if (self.val() === '2') {
$('#report-by-status').hide();
$('#report-by-user').hide();
$('#report-by-date').show();
$('#report-by-email').hide();
} else if (self.val() === '3') {
$('#report-by-status').hide();
$('#report-by-user').hide();
$('#report-by-date').hide();
$('#report-by-email').show();
} }
}); });
}); });

Loading…
Cancel
Save