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

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