Правка в логике сортировки по статусам, отключил логику утверждения

parent 0b8e1b47
......@@ -274,11 +274,17 @@ input[type="checkbox"]
/* .b-basket-content */
.table.table-striped.admin.transactions thead tr th.status,
.table.table-striped.admin.transactions thead tr th.period
{
width: 1px;
}
.table.table-striped.admin.transactions thead tr th.status b
{
}
.table.table-striped.admin thead tr th.Timestamp
{
width: 1px;
......@@ -309,7 +315,7 @@ input[type="checkbox"]
.table.table-striped.admin thead tr th.Basket .basket-link
{
width: 530px;
width: 470px;
}
.table.table-striped.admin.viewid thead tr th.Basket .basket-link
......@@ -326,15 +332,26 @@ input[type="checkbox"]
.table.table-striped.admin thead tr th.Basket .quantity
{
text-align: center;
text-align: left;
width: 55px;
}
.table.table-striped.admin thead tr th.Basket .price
{
text-align: right;
width: 45px;
}
.table.table-striped.admin td.Basket
{
padding: 2px;
}
.table.table-striped.admin.transactions td.status
{
text-align: center;
}
.table.table-striped.admin.transactions td.OrderSum
{
font-weight: bold;
......@@ -385,7 +402,7 @@ input[type="checkbox"]
.b-basket-content .basket-link
{
display: inline-block;
width: 540px;
width: 470px;
}
table.viewid .b-basket-content table
......@@ -425,8 +442,8 @@ input[type="checkbox"]
.b-basket-content .price
{
display: inline-block;
width: 100px;
text-align: left;
width: 70px;
text-align: right;
}
table.viewid .b-basket-content .price
......@@ -568,3 +585,25 @@ input[type="checkbox"]
}
#table2excel
{
/*display: none;*/
}
.b-export-xls
{
margin: -10px 0 10px 0;
height: 30px;
clear: both;
}
button#btnExport {
float: right;
padding: 4px 12px;
color: #fff;
border-radius: 4px;
background-color: #337ab7;
border-color: #2e6da4;
border: 0;
}
\ No newline at end of file
//table2excel.js
;(function ( $, window, document, undefined ) {
var pluginName = "table2excel",
defaults = {
exclude: ".noExl",
name: "Table2Excel"
};
// The actual plugin constructor
function Plugin ( element, options ) {
this.element = element;
// jQuery has an extend method which merges the contents of two or
// more objects, storing the result in the first object. The first object
// is generally empty as we don't want to alter the default options for
// future instances of the plugin
//
this.settings = $.extend( {}, defaults, options );
this._defaults = defaults;
this._name = pluginName;
this.init();
}
Plugin.prototype = {
init: function () {
var e = this;
var utf8Heading = "<meta http-equiv=\"content-type\" content=\"application/vnd.ms-excel; charset=UTF-8\">";
e.template = {
head: "<html xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:x=\"urn:schemas-microsoft-com:office:excel\" xmlns=\"http://www.w3.org/TR/REC-html40\">" + utf8Heading + "<head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets>",
sheet: {
head: "<x:ExcelWorksheet><x:Name>",
tail: "</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet>"
},
mid: "</x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--></head><body>",
table: {
head: "<table>",
tail: "</table>"
},
foot: "</body></html>"
};
e.tableRows = [];
// get contents of table except for exclude
$(e.element).each( function(i,o) {
var tempRows = "";
$(o).find("tr").not(e.settings.exclude).each(function (i,p) {
tempRows += "<tr>";
$(p).find("td,th").not(e.settings.exclude).each(function (i,q) { // p did not exist, I corrected
var flag = $(q).find(e.settings.exclude); // does this <td> have something with an exclude class
if(flag.length >= 1) {
tempRows += "<td> </td>"; // exclude it!!
} else {
tempRows += "<td>" + $(q).html() + "</td>";
}
});
tempRows += "</tr>";
});
// exclude img tags
if(e.settings.exclude_img) {
tempRows = exclude_img(tempRows);
}
// exclude link tags
if(e.settings.exclude_links) {
tempRows = exclude_links(tempRows);
}
// exclude input tags
if(e.settings.exclude_inputs) {
tempRows = exclude_inputs(tempRows);
}
e.tableRows.push(tempRows);
});
e.tableToExcel(e.tableRows, e.settings.name, e.settings.sheetName);
},
tableToExcel: function (table, name, sheetName) {
var e = this, fullTemplate="", i, link, a;
e.format = function (s, c) {
return s.replace(/{(\w+)}/g, function (m, p) {
return c[p];
});
};
sheetName = typeof sheetName === "undefined" ? "Sheet" : sheetName;
e.ctx = {
worksheet: name || "Worksheet",
table: table,
sheetName: sheetName
};
fullTemplate= e.template.head;
if ( $.isArray(table) ) {
for (i in table) {
//fullTemplate += e.template.sheet.head + "{worksheet" + i + "}" + e.template.sheet.tail;
fullTemplate += e.template.sheet.head + sheetName + i + e.template.sheet.tail;
}
}
fullTemplate += e.template.mid;
if ( $.isArray(table) ) {
for (i in table) {
fullTemplate += e.template.table.head + "{table" + i + "}" + e.template.table.tail;
}
}
fullTemplate += e.template.foot;
for (i in table) {
e.ctx["table" + i] = table[i];
}
delete e.ctx.table;
var isIE = /*@cc_on!@*/false || !!document.documentMode; // this works with IE10 and IE11 both :)
//if (typeof msie !== "undefined" && msie > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./)) // this works ONLY with IE 11!!!
if (isIE) {
if (typeof Blob !== "undefined") {
//use blobs if we can
fullTemplate = e.format(fullTemplate, e.ctx); // with this, works with IE
fullTemplate = [fullTemplate];
//convert to array
var blob1 = new Blob(fullTemplate, { type: "text/html" });
window.navigator.msSaveBlob(blob1, getFileName(e.settings) );
} else {
//otherwise use the iframe and save
//requires a blank iframe on page called txtArea1
txtArea1.document.open("text/html", "replace");
txtArea1.document.write(e.format(fullTemplate, e.ctx));
txtArea1.document.close();
txtArea1.focus();
sa = txtArea1.document.execCommand("SaveAs", true, getFileName(e.settings) );
}
} else {
var blob = new Blob([e.format(fullTemplate, e.ctx)], {type: "application/vnd.ms-excel"});
window.URL = window.URL || window.webkitURL;
link = window.URL.createObjectURL(blob);
a = document.createElement("a");
a.download = getFileName(e.settings);
a.href = link;
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
}
return true;
}
};
function getFileName(settings) {
return ( settings.filename ? settings.filename : "table2excel" );
}
// Removes all img tags
function exclude_img(string) {
var _patt = /(\s+alt\s*=\s*"([^"]*)"|\s+alt\s*=\s*'([^']*)')/i;
return string.replace(/<img[^>]*>/gi, function myFunction(x){
var res = _patt.exec(x);
if (res !== null && res.length >=2) {
return res[2];
} else {
return "";
}
});
}
// Removes all link tags
function exclude_links(string) {
return string.replace(/<a[^>]*>|<\/a>/gi, "");
}
// Removes input params
function exclude_inputs(string) {
var _patt = /(\s+value\s*=\s*"([^"]*)"|\s+value\s*=\s*'([^']*)')/i;
return string.replace(/<input[^>]*>|<\/input>/gi, function myFunction(x){
var res = _patt.exec(x);
if (res !== null && res.length >=2) {
return res[2];
} else {
return "";
}
});
}
$.fn[ pluginName ] = function ( options ) {
var e = this;
e.each(function() {
if ( !$.data( e, "plugin_" + pluginName ) ) {
$.data( e, "plugin_" + pluginName, new Plugin( this, options ) );
}
});
// chain jQuery functions
return e;
};
})( jQuery, window, document );
......@@ -37,10 +37,17 @@ $(document).ready(function(){
' <span><%=data.date %></span><br /> \n' +
'');
// Шаблон ячейки status
var templateOrderStatusContent = _.template('\n'+
' <span class="order-id" data-order-id="<%=data.orderId %>" data-feed-id="<%=data.feedId %>"> \n' +
' <input type="checkbox" name="order-id" <%=data.confirmed %> <%=data.approved %>> \n' +
' </span> \n' +
'');
// Шаблон ячейки OrderID
var templateOrderIDContent = _.template('\n'+
' <span class="order-id" data-order-id="<%=data.orderId %>" data-feed-id="<%=data.feedId %>"> \n' +
' <input type="checkbox" name="order-id" <%=data.confirmed %> <%=data.approved %>> \n' +
' <a class="orderid-link" href="orderid/<%=data.feedId %>/<%=data.orderId %>" target="_blank"><%=data.orderId %></a> \n' +
' </span> \n' +
'');
......@@ -51,7 +58,6 @@ $(document).ready(function(){
'');
function valueFormat(value)
{
var
......@@ -119,10 +125,6 @@ $(document).ready(function(){
}
//console.log('AAA sortField = ', sortField, ' isDesc = ', isDesc);
if (dataLineChartStat.report == 'transactions') {
console.log('AAA dataLineChartStat = ', dataLineChartStat.ordersStatus);
}
// Подготовка данных для сортировки:
dataPeriod.forEach(function(dataTableItem, ind){
var dataTableSortItem = {};
......@@ -173,7 +175,7 @@ $(document).ready(function(){
$row = $('<tr class="transaction-item ' + trClass + '">');
$row.append($('<td class="OrderID">').append(templateOrderIDContent({
$row.append($('<td class="status">').append(templateOrderStatusContent({
data: {
feedId: item['ViewID'][0],
orderId: item['period'],
......@@ -181,6 +183,15 @@ $(document).ready(function(){
approved: (orderStatus && orderStatus.approved) ? 'disabled' : '',
}
})));
$row.append($('<td class="OrderID">').append(templateOrderIDContent({
data: {
feedId: item['ViewID'][0],
orderId: item['period'],
//confirmed: (orderStatus && !orderStatus.confirmed) ? '' : 'checked',
//approved: (orderStatus && orderStatus.approved) ? 'disabled' : '',
}
})));
} else {
$row = $('<tr>');
$row.append($('<td>').html(item['period']));
......@@ -235,6 +246,7 @@ $(document).ready(function(){
if (dataLineChartStat.report == 'transactions') {
$row = $('<tr class="total-orders all">');
$row.append($('<td>'));
$row.append($('<td>').html("Всего заказов: " + dataPeriod.length));
activeLines.forEach(function(item){
......@@ -257,6 +269,7 @@ $(document).ready(function(){
// Добавляем total-строки для статусов заказов:
ordersStatuses.forEach(function(item){
$row = $('<tr class="total-orders ' + item + '">');
$row.append($('<td>'));
$row.append($('<td class="count">').html("Заказов: <span></span>"));
activeLines.forEach(function(activeLine){
$row.append($('<td class="'+ activeLine +'">'));
......
......@@ -45,6 +45,7 @@ $(document).ready(function(){
$chartStatErrorMessage = $('.chart-graph-stat-error .message'),
periodStatsData,
//campaignStatsData,
$exportExcelButton = $("#btnExport"),
dataLineChartStat;
......@@ -221,6 +222,8 @@ $(document).ready(function(){
//$('.main-cat').addClass('selected');
renderLineChart();
renderHourTable();
$.TableStat.OrdersStatusReCalc();
}
},
error: function (e) {
......@@ -273,6 +276,16 @@ $(document).ready(function(){
$chartTable.show();
}
// Выгрузка таблицы в Excel
$exportExcelButton.click(function(){
var $tableToExcel = $("#table2excel");
$tableToExcel.table2excel({
exclude: ".noExl",
name: "Worksheet Name",
filename: $tableToExcel.data('content') + '.xls'
});
});
// Обработка контролов для таблицы transactions:
(function(){
......@@ -296,7 +309,7 @@ $(document).ready(function(){
});
// Клик на галочку подтверждения заказа:
$tableStat.on('change', 'td.OrderID input', function(e) {
$tableStat.on('change', 'td.status input', function(e) {
var
$this = $(this),
......@@ -335,6 +348,7 @@ $(document).ready(function(){
});
// Клик на Утвердить заказы:
/*
$('a.btn.approve').on('click', function(){
if (!confirm("Утвердить заказы за выбранный период?")) return false;
......@@ -382,10 +396,9 @@ $(document).ready(function(){
}
});
return false;
});
*/
// Пересчет кол-ва заказов по группам
function OrdersStatusReCalc()
......
......@@ -95,6 +95,13 @@ class Cabinet extends Common
$auth = $this->container->get(UserService::class);
$userId = $auth->getIdentity()->getId();
/** @var \App\Model\Feeds\Shops $shopsModel */
$shopsModel = $this->container->get(\App\Model\Feeds\Shops::class);
$shop = $shopsModel->findOne(['users_id' => $userId]);
if($shop) {
$shop_title = $shop->getTitle();
}
/** @var \App\Model\Feeds $feedsModel */
$feedsModel = $this->container->get(Feeds::class);
$feeds = $feedsModel->findAll(['clientid' => $userId])->toArray();
......@@ -154,6 +161,7 @@ class Cabinet extends Common
$periodStats['ordersStatus'] = $statuses;
}
$data['shop_title'] = $shop_title;
$data['feeds'] = $feeds;
$data['current_report'] = $report_type;
$data['current_period'] = $current_period;
......
......@@ -32,6 +32,7 @@ $this->headScript()
->appendFile('/js/c3.min.js')
->appendFile('/js/d3.min.js')
->appendFile('/js/datepicker.min.js')
->appendFile('/js/jquery.table2excel.js')
->appendFile('/js/script-feeds-stat-charts.js')
->appendFile('/js/script-feeds-stat-table.js')
->appendFile('/js/script-feeds-stat.js')
......@@ -69,6 +70,7 @@ if (!$error) {
$reports_list = $this->reports_list;
$periods_list = $this->periods_list;
$colors_active_lines = $this->colors_active_lines;
$shop_title = $this->shop_title;
$data_request_link = $this->url('user.cabinet', ['lang' => $this->lang, 'report' => $current_report]);
$system_link = $this->url('adm.system.actions');
......@@ -176,8 +178,10 @@ if (!$error) {
<?php /* Переключатель статусов заказов */ ?>
<div class="b-filter__switch category-orders">
<span class="b-filter__switch-item text all m-filter__switch-item_active" data-order-category="all"><?= _t('Все')?></span>
<?php /* ?>
<span class="b-filter__switch-item text approved" data-order-category="approved"><?= _t('Согласованны')?></span>
<span class="b-filter__switch-item text confirmed" data-order-category="confirmed"><?= _t('Приняты')?></span>
<?php */ ?>
<span class="b-filter__switch-item text confirmed" data-order-category="confirmed"><?= _t('Подтверждены')?></span>
<span class="b-filter__switch-item text rejected" data-order-category="rejected"><?= _t('Отклонены')?></span>
</div>
<?php endif ?>
......@@ -187,6 +191,9 @@ if (!$error) {
<table id="table-line" class="table table-striped admin <?= $current_report ?> all" data-link="<?=$data_request_link ?>">
<thead class="metric sortable">
<tr>
<th class="status">
<b class="not-sorted">Подтвержден</b>
</th>
<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>
......@@ -215,10 +222,39 @@ if (!$error) {
</tbody>
</table>
<?php if($current_report == 'transactions'): ?>
<?php /* if($current_report == 'transactions'): ?>
<div class="b-orders_controls">
<a class="btn btn-primary approve" href="<?= $system_link ?>">Утвердить заказы</a>
</div>
<?php endif; */ ?>
<?php if($current_report == 'transactions'): ?>
<table id="table2excel" data-content="shop-<?= $shop_title ?>" width="100%">
<?php /* ?>
<thead class="metric sortable">
<tr>
<th>
<b><?= _t($report_main_cat[0]['title'])?></b>
</th>
<?php foreach($report_cats as $name => $title): ?>
<?php if ($name == 'Timestamp'): ?>
<th><b><?= _t('Дата время')?></b></th>
<?php else: ?>
<?php if (!in_array($name, ['ViewID', 'Basket'])): ?>
<th><b><?= _t($title)?></b></th>
<?php endif; ?>
<?php endif; ?>
<?php endforeach; ?>
</tr>
</thead>
<tbody>
</tbody>
<?php */ ?>
</table>
<div class="b-export-xls">
<button id="btnExport"> EXPORT to Excel </button>
</div>
<?php endif; ?>
</div>
......
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