Формирование таблицы заказов для excel-выгрузки

parent cdcf726b
...@@ -13,13 +13,6 @@ return [ ...@@ -13,13 +13,6 @@ return [
'year' => 'год', 'year' => 'год',
], ],
'colors_active_lines' => [ 'colors_active_lines' => [
/*
'shows' => '#2CA02C',
'clicks' => '#D62728',
'transactions' => '#1F77B4',
'salemoney' => '#FF7F0E',
'admoney' => '#9467BD',
*/
'Views' => '#2CA02C', 'Views' => '#2CA02C',
'Clicks' => '#D62728', 'Clicks' => '#D62728',
'Orders' => '#1F77B4', 'Orders' => '#1F77B4',
...@@ -52,12 +45,6 @@ return [ ...@@ -52,12 +45,6 @@ return [
'OrderSum' => 'Сумма', 'OrderSum' => 'Сумма',
'AdMoney' => 'Комиссия' 'AdMoney' => 'Комиссия'
] ]
/*
$cats => [
'localmoney' => 'localmoney',
'usdollarmoney' => 'usdollarmoney'
];
*/
], ],
] ]
] ]
......
...@@ -587,7 +587,7 @@ input[type="checkbox"] ...@@ -587,7 +587,7 @@ input[type="checkbox"]
#table2excel #table2excel
{ {
/*display: none;*/ display: none;
} }
.b-export-xls .b-export-xls
......
...@@ -2,8 +2,11 @@ $(document).ready(function(){ ...@@ -2,8 +2,11 @@ $(document).ready(function(){
var var
$table = $('#table-line'), $table = $('#table-line'),
$tableToExcel = $('#table2excel'),
$tableContent = $('<tbody>'), $tableContent = $('<tbody>'),
$tableToExcelContent = $('<tbody>'),
$tableBody = $table.find('tbody').first(), $tableBody = $table.find('tbody').first(),
$tableToExcelBody = $tableToExcel.find('tbody').first(),
activeLines = [], activeLines = [],
currentActiveLine, currentActiveLine,
currencyFields = ['admoney', 'salemoney', 'usdollarmoney', 'localmoney', 'AdMoney', 'OrderSum', 'Price'], currencyFields = ['admoney', 'salemoney', 'usdollarmoney', 'localmoney', 'AdMoney', 'OrderSum', 'Price'],
...@@ -84,6 +87,7 @@ $(document).ready(function(){ ...@@ -84,6 +87,7 @@ $(document).ready(function(){
{ {
return dataDate.split(' ')[0]; return dataDate.split(' ')[0];
} }
function getHourMinValue(dataDate) function getHourMinValue(dataDate)
{ {
var var
...@@ -174,7 +178,6 @@ $(document).ready(function(){ ...@@ -174,7 +178,6 @@ $(document).ready(function(){
} }
$row = $('<tr class="transaction-item ' + trClass + '">'); $row = $('<tr class="transaction-item ' + trClass + '">');
$row.append($('<td class="status">').append(templateOrderStatusContent({ $row.append($('<td class="status">').append(templateOrderStatusContent({
data: { data: {
feedId: item['ViewID'][0], feedId: item['ViewID'][0],
...@@ -183,7 +186,6 @@ $(document).ready(function(){ ...@@ -183,7 +186,6 @@ $(document).ready(function(){
approved: (orderStatus && orderStatus.approved) ? 'disabled' : '', approved: (orderStatus && orderStatus.approved) ? 'disabled' : '',
} }
}))); })));
$row.append($('<td class="OrderID">').append(templateOrderIDContent({ $row.append($('<td class="OrderID">').append(templateOrderIDContent({
data: { data: {
feedId: item['ViewID'][0], feedId: item['ViewID'][0],
...@@ -192,6 +194,10 @@ $(document).ready(function(){ ...@@ -192,6 +194,10 @@ $(document).ready(function(){
//approved: (orderStatus && orderStatus.approved) ? 'disabled' : '', //approved: (orderStatus && orderStatus.approved) ? 'disabled' : '',
} }
}))); })));
$rowExcel = $('<tr class="' + trClass + '">');
$rowExcel.append($('<td>').html(item['period']));
} else { } else {
$row = $('<tr>'); $row = $('<tr>');
$row.append($('<td>').html(item['period'])); $row.append($('<td>').html(item['period']));
...@@ -206,6 +212,7 @@ $(document).ready(function(){ ...@@ -206,6 +212,7 @@ $(document).ready(function(){
$row.append($('<td class="'+ line +'">').append(templateTimestampContent({ $row.append($('<td class="'+ line +'">').append(templateTimestampContent({
data: {date: getDateValue(item[line]), time: getHourMinValue(item[line])} data: {date: getDateValue(item[line]), time: getHourMinValue(item[line])}
}))); })));
$rowExcel.append($('<td>').append(item[line]));
} else if (line == 'ViewID') { } else if (line == 'ViewID') {
$row.append($('<td class="'+ line +'">').append(templateViewIDContent({ $row.append($('<td class="'+ line +'">').append(templateViewIDContent({
data: {feedId: item[line][0], viewId: item[line][1]} data: {feedId: item[line][0], viewId: item[line][1]}
...@@ -213,9 +220,11 @@ $(document).ready(function(){ ...@@ -213,9 +220,11 @@ $(document).ready(function(){
} else { } else {
currentActiveLine = line; currentActiveLine = line;
$row.append($('<td class="'+ line +'">').html(valueFormat(item[line]))); $row.append($('<td class="'+ line +'">').html(valueFormat(item[line])));
$rowExcel.append($('<td>').html(valueFormat(item[line])));
} }
}); });
$row.appendTo($tableContent); $row.appendTo($tableContent);
$rowExcel.appendTo($tableToExcelContent);
}); });
// Добавляем строку "Итого" для отчета 'common': // Добавляем строку "Итого" для отчета 'common':
...@@ -249,6 +258,9 @@ $(document).ready(function(){ ...@@ -249,6 +258,9 @@ $(document).ready(function(){
$row.append($('<td>')); $row.append($('<td>'));
$row.append($('<td>').html("Всего заказов: " + dataPeriod.length)); $row.append($('<td>').html("Всего заказов: " + dataPeriod.length));
$rowExcel = $('<tr>');
$rowExcel.append($('<td>').html("<b>Всего заказов: " + dataPeriod.length + '</b>'));
activeLines.forEach(function(item){ activeLines.forEach(function(item){
currentActiveLine = item; currentActiveLine = item;
var isNotSumValue = notFormatFields.indexOf(currentActiveLine) > -1; var isNotSumValue = notFormatFields.indexOf(currentActiveLine) > -1;
...@@ -263,18 +275,32 @@ $(document).ready(function(){ ...@@ -263,18 +275,32 @@ $(document).ready(function(){
} }
$row.append($('<td class="'+ item +'">').html(valueFormat(totalValue))); $row.append($('<td class="'+ item +'">').html(valueFormat(totalValue)));
if (['ViewID', 'Basket'].indexOf(currentActiveLine)<0) {
$rowExcel.append($('<td>').html('<b>' + valueFormat(totalValue) + '</b>'));
}
}); });
$row.appendTo($tableContent); $row.appendTo($tableContent);
$rowExcel.appendTo($tableToExcelContent);
// Добавляем total-строки для статусов заказов: // Добавляем total-строки для статусов заказов:
ordersStatuses.forEach(function(item){ ordersStatuses.forEach(function(item){
$row = $('<tr class="total-orders ' + item + '">'); $row = $('<tr class="total-orders ' + item + '">');
$row.append($('<td>')); $row.append($('<td>'));
$row.append($('<td class="count">').html("Заказов: <span></span>")); $row.append($('<td class="count">').html("Заказов: <span></span>"));
$rowExcel = $('<tr class="total-orders ' + item + '">');
$rowExcel.append($('<td class="count">').html("<b>Заказов: <span></span>"));
activeLines.forEach(function(activeLine){ activeLines.forEach(function(activeLine){
$row.append($('<td class="'+ activeLine +'">')); $row.append($('<td class="'+ activeLine +'">'));
if (['ViewID', 'Basket'].indexOf(activeLine)<0) {
$rowExcel.append($('<td class="'+ activeLine +'">'));
}
}); });
$row.appendTo($tableContent); $row.appendTo($tableContent);
$rowExcel.appendTo($tableToExcelContent);
}); });
} }
...@@ -284,14 +310,13 @@ $(document).ready(function(){ ...@@ -284,14 +310,13 @@ $(document).ready(function(){
$.extend({ $.extend({
TableStat: { TableStat: {
Render: function(dataLineChartStat) { Render: function(dataLineChartStat) {
//console.log('AAA TableStat render: ', dataLineChartStat);
// Формируем список переключателей (категорий) activeLines: // Формируем список переключателей (категорий) activeLines:
activeLines = []; activeLines = [];
$('thead.metric.sortable th b.cat', $table).each(function(){ $('thead.metric.sortable th b.cat', $table).each(function(){
activeLines.push($(this).attr('id')); activeLines.push($(this).attr('id'));
}); });
//console.log('AAA TableStat render: ', dataLineChartStat);
//console.log('AAA activeLines: ', activeLines); //console.log('AAA activeLines: ', activeLines);
if (dataLineChartStat.type == 'interval') { if (dataLineChartStat.type == 'interval') {
...@@ -303,6 +328,7 @@ $(document).ready(function(){ ...@@ -303,6 +328,7 @@ $(document).ready(function(){
} }
$tableBody.html('').append($tableContent.children()); $tableBody.html('').append($tableContent.children());
$tableToExcelBody.html('').append($tableToExcelContent.children());
}, },
// Определяем список категорий, отмеченных галочками в таблице: // Определяем список категорий, отмеченных галочками в таблице:
CheckedCategories: function() { CheckedCategories: function() {
...@@ -314,6 +340,7 @@ $(document).ready(function(){ ...@@ -314,6 +340,7 @@ $(document).ready(function(){
}); });
return listCats; return listCats;
}, },
// Пересчитываем кол-во заказов по статусам:
OrdersStatusReCalc: function() { OrdersStatusReCalc: function() {
console.log('AAA OrdersStatusReCalc'); console.log('AAA OrdersStatusReCalc');
...@@ -321,9 +348,11 @@ $(document).ready(function(){ ...@@ -321,9 +348,11 @@ $(document).ready(function(){
ordersStatuses.forEach(function(item){ ordersStatuses.forEach(function(item){
var var
$trStatus = $('tr.transaction-item.'+ item, $table), $trStatus = $('tr.transaction-item.'+ item, $table),
$trTotalStatus = $('tr.total-orders.'+ item, $table); $trTotalStatus = $('tr.total-orders.'+ item, $table),
$trTotalStatusToExcel = $('tr.total-orders.'+ item, $tableToExcel);
$('td.count span', $trTotalStatus).html($trStatus.length); $('td.count span', $trTotalStatus).html($trStatus.length);
$('td.count span', $trTotalStatusToExcel).html($trStatus.length);
activeLines.forEach(function(activeLine){ activeLines.forEach(function(activeLine){
currentActiveLine = activeLine; currentActiveLine = activeLine;
...@@ -335,6 +364,7 @@ $(document).ready(function(){ ...@@ -335,6 +364,7 @@ $(document).ready(function(){
totalValue += parseFloat($('td.'+ activeLine, $this).html().replace(',','')); totalValue += parseFloat($('td.'+ activeLine, $this).html().replace(',',''));
}); });
$('td.'+ activeLine, $trTotalStatus).html(valueFormat(totalValue)); $('td.'+ activeLine, $trTotalStatus).html(valueFormat(totalValue));
$('td.'+ activeLine, $trTotalStatusToExcel).html(valueFormat(totalValue));
} }
}); });
......
...@@ -278,6 +278,9 @@ $(document).ready(function(){ ...@@ -278,6 +278,9 @@ $(document).ready(function(){
// Выгрузка таблицы в Excel // Выгрузка таблицы в Excel
$exportExcelButton.click(function(){ $exportExcelButton.click(function(){
console.log('AAA exportExcel');
return false;
var $tableToExcel = $("#table2excel"); var $tableToExcel = $("#table2excel");
$tableToExcel.table2excel({ $tableToExcel.table2excel({
exclude: ".noExl", exclude: ".noExl",
......
...@@ -191,9 +191,11 @@ if (!$error) { ...@@ -191,9 +191,11 @@ if (!$error) {
<table id="table-line" class="table table-striped admin <?= $current_report ?> all" data-link="<?=$data_request_link ?>"> <table id="table-line" class="table table-striped admin <?= $current_report ?> all" data-link="<?=$data_request_link ?>">
<thead class="metric sortable"> <thead class="metric sortable">
<tr> <tr>
<?php if($current_report == 'transactions'): ?>
<th class="status"> <th class="status">
<b class="not-sorted">Подтвержден</b> <b class="not-sorted">Подтвержден</b>
</th> </th>
<?php endif; ?>
<th class="period" data-id="period"> <th class="period" data-id="period">
<b class="main-cat selected <?php if(!$main_cat['isSorted']): ?>not-sorted<?php endif; ?>" data-cat="<?= $main_cat['name'] ?>"><?= _t($main_cat['title'])?></b> <b class="main-cat selected <?php if(!$main_cat['isSorted']): ?>not-sorted<?php endif; ?>" data-cat="<?= $main_cat['name'] ?>"><?= _t($main_cat['title'])?></b>
</th> </th>
...@@ -230,11 +232,10 @@ if (!$error) { ...@@ -230,11 +232,10 @@ if (!$error) {
<?php if($current_report == 'transactions'): ?> <?php if($current_report == 'transactions'): ?>
<table id="table2excel" data-content="shop-<?= $shop_title ?>" width="100%"> <table id="table2excel" data-content="shop-<?= $shop_title ?>" width="100%">
<?php /* ?> <thead>
<thead class="metric sortable">
<tr> <tr>
<th> <th>
<b><?= _t($report_main_cat[0]['title'])?></b> <b><?= _t($main_cat['title'])?></b>
</th> </th>
<?php foreach($report_cats as $name => $title): ?> <?php foreach($report_cats as $name => $title): ?>
<?php if ($name == 'Timestamp'): ?> <?php if ($name == 'Timestamp'): ?>
...@@ -249,7 +250,6 @@ if (!$error) { ...@@ -249,7 +250,6 @@ if (!$error) {
</thead> </thead>
<tbody> <tbody>
</tbody> </tbody>
<?php */ ?>
</table> </table>
<div class="b-export-xls"> <div class="b-export-xls">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment