ver. 0.274 - ShopProduct mass_edit + tree UI cleanup
This commit is contained in:
@@ -52,6 +52,49 @@ if (!empty($_COOKIE['cookie_menus'])) {
|
||||
<script type="text/javascript" src="/libraries/jquery/lozad.js"></script>
|
||||
|
||||
<style type="text/css">
|
||||
#fg-article-edit .layout-tree-toggle {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
padding: 0;
|
||||
margin-right: 4px;
|
||||
color: #666;
|
||||
cursor: pointer;
|
||||
text-indent: 0;
|
||||
background-image: none !important;
|
||||
}
|
||||
|
||||
#fg-article-edit .layout-tree-toggle:focus,
|
||||
#fg-article-edit .layout-tree-toggle:active,
|
||||
#fg-article-edit .layout-tree-toggle:focus-visible {
|
||||
outline: none;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
#fg-article-edit li.sort-expanded > div .layout-tree-toggle i {
|
||||
transform: rotate(90deg);
|
||||
}
|
||||
|
||||
#fg-article-edit .sortable li.sort-branch > div > .layout-tree-toggle {
|
||||
display: inline-flex;
|
||||
float: none;
|
||||
margin-right: 4px;
|
||||
}
|
||||
|
||||
#fg-article-edit .menu_sortable .icheckbox_minimal-blue {
|
||||
margin-top: 0;
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
#fg-article-edit .menu_sortable .g-checkbox {
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.jconfirm.table-list-confirm-dialog .jconfirm-row {
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
@@ -371,9 +414,39 @@ if (!empty($_COOKIE['cookie_menus'])) {
|
||||
flash_swf_url: '/../libraries/plupload/plupload.flash.swf'
|
||||
});
|
||||
|
||||
function refreshTreeDisclosureState() {
|
||||
$('ol.sortable li').each(function() {
|
||||
var $li = $(this);
|
||||
var hasChildren = $li.children('ol').children('li').length > 0;
|
||||
var $disclose = $li.children('div').children('.disclose');
|
||||
|
||||
if (hasChildren) {
|
||||
$li.removeClass('sort-leaf');
|
||||
if (!$li.hasClass('sort-collapsed') && !$li.hasClass('sort-expanded')) {
|
||||
$li.addClass('sort-collapsed');
|
||||
}
|
||||
$li.addClass('sort-branch');
|
||||
$disclose.attr('aria-expanded', $li.hasClass('sort-expanded') ? 'true' : 'false');
|
||||
$disclose.show();
|
||||
} else {
|
||||
$li.removeClass('sort-branch sort-collapsed sort-expanded').addClass('sort-leaf');
|
||||
$disclose.attr('aria-expanded', 'false');
|
||||
$disclose.hide();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if ($.fn && typeof $.fn.iCheck === 'function') {
|
||||
$('#fg-article-edit .menu_sortable .g-checkbox').iCheck({
|
||||
checkboxClass: 'icheckbox_minimal-blue',
|
||||
radioClass: 'iradio_minimal-blue'
|
||||
});
|
||||
}
|
||||
|
||||
$('ol.sortable').nestedSortable({
|
||||
forcePlaceholderSize: true,
|
||||
handle: 'div',
|
||||
cancel: 'input,textarea,button,select,option,.icheckbox_minimal-blue,.iradio_minimal-blue,ins.iCheck-helper',
|
||||
helper: 'clone',
|
||||
items: 'li',
|
||||
opacity: .6,
|
||||
@@ -390,8 +463,17 @@ if (!empty($_COOKIE['cookie_menus'])) {
|
||||
}
|
||||
});
|
||||
|
||||
refreshTreeDisclosureState();
|
||||
|
||||
$('.disclose').on('click', function() {
|
||||
$(this).closest('li').toggleClass('sort-collapsed').toggleClass('sort-expanded');
|
||||
var $li = $(this).closest('li');
|
||||
if (!$li.hasClass('sort-branch')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$li.toggleClass('sort-collapsed').toggleClass('sort-expanded');
|
||||
$(this).attr('aria-expanded', $li.hasClass('sort-expanded') ? 'true' : 'false');
|
||||
this.blur();
|
||||
});
|
||||
|
||||
$('.disclose').mousedown(function(e) {
|
||||
@@ -423,10 +505,10 @@ if (!empty($_COOKIE['cookie_menus'])) {
|
||||
});
|
||||
|
||||
<?php foreach ($cookiePages as $key => $val): ?>
|
||||
<?php if ($val): ?>$('.<?= htmlspecialchars((string)$key, ENT_QUOTES, 'UTF-8') ?>').children('div').children('span.disclose').click();<?php endif; ?>
|
||||
<?php if ($val): ?>$('.list_<?= (int)$key ?>').children('div').children('.disclose').click();<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
<?php foreach ($cookieMenus as $key => $val): ?>
|
||||
<?php if ($val): ?>$('.menu_<?= (int)$key ?>').children('div').children('span.disclose').click();<?php endif; ?>
|
||||
<?php if ($val): ?>$('.menu_<?= (int)$key ?>').children('div').children('.disclose').click();<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
|
||||
$('body').on('change', '.image-alt', function() {
|
||||
|
||||
@@ -3,8 +3,11 @@
|
||||
<? foreach ( $this -> pages as $page ):?>
|
||||
<li id="list_<?= $page['id'];?>" idk="<?= $page['id'];?>" class="sort-nonesting list_<?= $page['id'];?>" menu="<?= $page['menu_id'];?>">
|
||||
<div class="content <?= $this -> step < 2 ? $tmp = 'content_page' : $tmp = 'content_page_last_level';?>" <? if ( !$page['status'] ) echo 'style="color: #cc0000;"';?>>
|
||||
<span class="disclose"><span></span></span>
|
||||
<input type="checkbox" class="g-checkbox" name="pages[]" value="<?= $page['id'];?>" <? if ( is_array( $this -> article_pages ) and in_array( $page['id'], $this -> article_pages ) ):?>checked="checked"<? endif;?> /><?= $page['title'];?>
|
||||
<button type="button" class="disclose layout-tree-toggle" aria-expanded="false" title="Rozwin / zwin">
|
||||
<i class="fa fa-caret-right"></i>
|
||||
</button>
|
||||
<input type="checkbox" class="g-checkbox" name="pages[]" id="article_page_<?= $page['id'];?>" value="<?= $page['id'];?>" <? if ( is_array( $this -> article_pages ) and in_array( $page['id'], $this -> article_pages ) ):?>checked="checked"<? endif;?> />
|
||||
<label for="article_page_<?= $page['id'];?>" class="mb0"><?= $page['title'];?></label>
|
||||
</div>
|
||||
<?= \Tpl::view( 'articles/subpages-list', [
|
||||
'pages' => $page['subpages'],
|
||||
|
||||
@@ -15,7 +15,9 @@ foreach ($menus as $menu):
|
||||
<ol class="sortable" id="sortable_<?= $menuId; ?>" menu-id="<?= $menuId; ?>">
|
||||
<li id="list_<?= $menuId; ?>" class="menu_<?= $menuId; ?>" menu="<?= $menuId; ?>">
|
||||
<div class="context_0 content content_menu">
|
||||
<span class="disclose"><span></span></span>
|
||||
<button type="button" class="disclose layout-tree-toggle" aria-expanded="false" title="Rozwin / zwin">
|
||||
<i class="fa fa-caret-right"></i>
|
||||
</button>
|
||||
<?php if ($menuStatus !== 1): ?><i class="fa fa-ban fa-lg text-danger" title="Menu nieaktywne"></i><?php endif; ?>
|
||||
<b>Menu: <?= htmlspecialchars($menuName, ENT_QUOTES, 'UTF-8'); ?></b>
|
||||
<div class="btn-group ml20 pull-right">
|
||||
@@ -61,6 +63,31 @@ echo $grid->draw();
|
||||
?>
|
||||
<script type="text/javascript" src="/libraries/jquery-nested-sortable/jquery.mjs.nestedSortable.js"></script>
|
||||
<style type="text/css">
|
||||
.layout-tree-toggle {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
padding: 0;
|
||||
margin-right: 4px;
|
||||
color: #666;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.layout-tree-toggle:focus,
|
||||
.layout-tree-toggle:active,
|
||||
.layout-tree-toggle:focus-visible {
|
||||
outline: none;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
li.sort-expanded > div .layout-tree-toggle i {
|
||||
transform: rotate(90deg);
|
||||
}
|
||||
|
||||
.jconfirm.table-list-confirm-dialog .jconfirm-row {
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
@@ -86,6 +113,28 @@ echo $grid->draw();
|
||||
var cookieMenus = <?= json_encode($cookieMenus, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); ?>;
|
||||
|
||||
$(document).ready(function() {
|
||||
function refreshTreeDisclosureState() {
|
||||
$('ol.sortable li').each(function() {
|
||||
var $li = $(this);
|
||||
var hasChildren = $li.children('ol').children('li').length > 0;
|
||||
var $disclose = $li.children('div').children('.disclose');
|
||||
|
||||
if (hasChildren) {
|
||||
$li.removeClass('sort-leaf');
|
||||
if (!$li.hasClass('sort-collapsed') && !$li.hasClass('sort-expanded')) {
|
||||
$li.addClass('sort-collapsed');
|
||||
}
|
||||
$li.addClass('sort-branch');
|
||||
$disclose.attr('aria-expanded', $li.hasClass('sort-expanded') ? 'true' : 'false');
|
||||
$disclose.show();
|
||||
} else {
|
||||
$li.removeClass('sort-branch sort-collapsed sort-expanded').addClass('sort-leaf');
|
||||
$disclose.attr('aria-expanded', 'false');
|
||||
$disclose.hide();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function confirmDialog(message, onConfirm) {
|
||||
if (typeof $.confirm === 'function') {
|
||||
$.confirm({
|
||||
@@ -167,12 +216,22 @@ echo $grid->draw();
|
||||
isTree: true,
|
||||
expandOnHover: 700,
|
||||
stop: function() {
|
||||
refreshTreeDisclosureState();
|
||||
save_pages_order();
|
||||
}
|
||||
});
|
||||
|
||||
refreshTreeDisclosureState();
|
||||
|
||||
$('.disclose').on('click', function() {
|
||||
$(this).closest('li').toggleClass('sort-collapsed').toggleClass('sort-expanded');
|
||||
var $li = $(this).closest('li');
|
||||
if (!$li.hasClass('sort-branch')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$li.toggleClass('sort-collapsed').toggleClass('sort-expanded');
|
||||
$(this).attr('aria-expanded', $li.hasClass('sort-expanded') ? 'true' : 'false');
|
||||
this.blur();
|
||||
});
|
||||
|
||||
$('.sortable *').mousedown(function() {
|
||||
@@ -205,13 +264,13 @@ echo $grid->draw();
|
||||
|
||||
Object.keys(cookiePages || {}).forEach(function(key) {
|
||||
if (String(cookiePages[key]) === '1') {
|
||||
$('.list_' + key).children('div').children('span.disclose').click();
|
||||
$('.list_' + key).children('div').children('.disclose').click();
|
||||
}
|
||||
});
|
||||
|
||||
Object.keys(cookieMenus || {}).forEach(function(key) {
|
||||
if (String(cookieMenus[key]) === '1') {
|
||||
$('.menu_' + key).children('div').children('span.disclose').click();
|
||||
$('.menu_' + key).children('div').children('.disclose').click();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -19,7 +19,9 @@ if (empty($pages)) {
|
||||
<li id="list_<?= $pageId; ?>" class="list_<?= $pageId; ?>" menu="<?= $menuId; ?>">
|
||||
<div class="content">
|
||||
<div class="menu-box-title">
|
||||
<span class="disclose"><span></span></span>
|
||||
<button type="button" class="disclose layout-tree-toggle" aria-expanded="false" title="Rozwin / zwin">
|
||||
<i class="fa fa-caret-right"></i>
|
||||
</button>
|
||||
<?php if ($status !== 1): ?><i class="fa fa-ban fa-lg text-danger" title="Strona nieaktywna"></i><?php endif; ?>
|
||||
<?php if ($start === 1): ?><i class="fa fa-star fa-lg text-system" title="Strona startowa"></i><?php endif; ?>
|
||||
<?= htmlspecialchars($title, ENT_QUOTES, 'UTF-8'); ?>
|
||||
|
||||
158
admin/templates/shop-product/mass-edit-custom-script.php
Normal file
158
admin/templates/shop-product/mass-edit-custom-script.php
Normal file
@@ -0,0 +1,158 @@
|
||||
<script type="text/javascript" src="/libraries/jquery-nested-sortable/jquery.mjs.nestedSortable.js"></script>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
$('ol.sortable').nestedSortable({
|
||||
forcePlaceholderSize: true,
|
||||
handle: 'div.content',
|
||||
cancel: 'input,textarea,button,select,option,.icheckbox_minimal-blue,.iradio_minimal-blue,ins.iCheck-helper',
|
||||
helper: 'original',
|
||||
items: 'li',
|
||||
opacity: .6,
|
||||
placeholder: 'placeholder',
|
||||
revert: 250,
|
||||
tabSize: 25,
|
||||
tolerance: 'pointer',
|
||||
toleranceElement: '> div.content',
|
||||
maxLevels: 4,
|
||||
isTree: true,
|
||||
expandOnHover: 700,
|
||||
isAllowed: function() { return false; }
|
||||
});
|
||||
|
||||
function refreshTreeDisclosureState() {
|
||||
$('ol.sortable li').each(function() {
|
||||
var $li = $(this);
|
||||
var hasChildren = $li.children('ol').children('li').length > 0;
|
||||
var $disclose = $li.children('div').children('.disclose');
|
||||
|
||||
if (hasChildren) {
|
||||
$li.removeClass('sort-leaf');
|
||||
if (!$li.hasClass('sort-collapsed') && !$li.hasClass('sort-expanded'))
|
||||
$li.addClass('sort-collapsed');
|
||||
$li.addClass('sort-branch');
|
||||
$disclose.attr('aria-expanded', $li.hasClass('sort-expanded') ? 'true' : 'false');
|
||||
$disclose.show();
|
||||
} else {
|
||||
$li.removeClass('sort-branch sort-collapsed sort-expanded').addClass('sort-leaf');
|
||||
$disclose.attr('aria-expanded', 'false');
|
||||
$disclose.hide();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
refreshTreeDisclosureState();
|
||||
|
||||
// Inicjalizacja iCheck — osobno dla produktów i kategorii
|
||||
if ($.fn && typeof $.fn.iCheck === 'function') {
|
||||
$('.product-item .g-checkbox').iCheck({
|
||||
checkboxClass: 'icheckbox_minimal-blue',
|
||||
radioClass: 'iradio_minimal-blue'
|
||||
});
|
||||
$('#sortable input.g-checkbox').iCheck({
|
||||
checkboxClass: 'icheckbox_minimal-blue',
|
||||
radioClass: 'iradio_minimal-blue'
|
||||
});
|
||||
}
|
||||
|
||||
$('body').on('click', '.disclose', function() {
|
||||
var $li = $(this).closest('li');
|
||||
if (!$li.hasClass('sort-branch')) return;
|
||||
$li.toggleClass('sort-collapsed').toggleClass('sort-expanded');
|
||||
$(this).attr('aria-expanded', $li.hasClass('sort-expanded') ? 'true' : 'false');
|
||||
this.blur();
|
||||
});
|
||||
|
||||
$('.disclose').mousedown(function(e) {
|
||||
if (e.which === 1) {
|
||||
var category_id = $(this).parent('div').parent('li').attr('id');
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/ajax.php',
|
||||
data: { a: 'cookie_categories', category_id: category_id }
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
<?php
|
||||
$array = isset($_COOKIE['cookie_categories']) ? @unserialize($_COOKIE['cookie_categories']) : [];
|
||||
if (is_array($array)):
|
||||
foreach ($array as $key => $val):
|
||||
if ($val):
|
||||
?>
|
||||
$('#<?= $key; ?>').children('div').children('button.disclose').click();
|
||||
<?php
|
||||
endif;
|
||||
endforeach;
|
||||
endif;
|
||||
?>
|
||||
|
||||
$('.select-all').click(function() {
|
||||
$('.product-item .g-checkbox').iCheck('check');
|
||||
});
|
||||
|
||||
$('.deselect-all').click(function() {
|
||||
$('.product-item .g-checkbox').iCheck('uncheck');
|
||||
});
|
||||
|
||||
$('body').on('click', 'span[field-id="discount_percent"]', function() {
|
||||
$('.ajax-msg').remove();
|
||||
var discount_percent = $('#discount_percent').val();
|
||||
var products = [];
|
||||
$('input[name="products[]"]:checked').each(function() {
|
||||
products.push($(this).val());
|
||||
});
|
||||
|
||||
function saveProduct(index) {
|
||||
if (index < products.length) {
|
||||
$.ajax({
|
||||
url: '/admin/shop_product/mass_edit_save/',
|
||||
type: 'post',
|
||||
data: { discount_percent: discount_percent, products: [products[index]] },
|
||||
success: function(data) {
|
||||
data = JSON.parse(data);
|
||||
if (data.status == 'ok') {
|
||||
if (data.price_brutto_promo)
|
||||
$('label[for="product' + products[index] + '"]').append(' <span class="ajax-msg text-success">cena promocyjna: ' + data.price_brutto_promo + ' zł, cena zwykła: ' + data.price_brutto + '</span>');
|
||||
else
|
||||
$('label[for="product' + products[index] + '"]').append(' <span class="ajax-msg text-success">cena zwykła: ' + data.price_brutto + '</span>');
|
||||
} else {
|
||||
alert('Błąd przy zapisie produktu: ' + products[index]);
|
||||
}
|
||||
saveProduct(index + 1);
|
||||
},
|
||||
error: function() {
|
||||
alert('Błąd przy zapisie produktu: ' + products[index]);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
$.alert({
|
||||
title: 'Informacja',
|
||||
content: 'Zakończono zapisywanie produktów',
|
||||
type: 'orange',
|
||||
closeIcon: true,
|
||||
closeIconClass: 'fa fa-close',
|
||||
typeAnimated: true,
|
||||
animation: 'opacity',
|
||||
useBootstrap: false,
|
||||
theme: 'modern',
|
||||
autoClose: 'cancel|10000',
|
||||
icon: 'fa fa-exclamation',
|
||||
buttons: {
|
||||
confirm: {
|
||||
text: 'Zamknij',
|
||||
btnClass: 'btn-blue',
|
||||
keys: ['enter'],
|
||||
action: function() {}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (products.length > 0) {
|
||||
saveProduct(0);
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@@ -1,4 +1,56 @@
|
||||
<div class="panel mb50 panel-primary">
|
||||
<style type="text/css">
|
||||
.layout-tree-toggle {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
padding: 0;
|
||||
margin-right: 4px;
|
||||
color: #666;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.layout-tree-toggle:focus,
|
||||
.layout-tree-toggle:active,
|
||||
.layout-tree-toggle:focus-visible {
|
||||
outline: none;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
li.sort-expanded > div .layout-tree-toggle i {
|
||||
transform: rotate(90deg);
|
||||
}
|
||||
|
||||
#mass-edit-panel .product-item {
|
||||
margin-bottom: 4px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
#mass-edit-panel .product-item label {
|
||||
cursor: pointer;
|
||||
font-weight: normal;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
#mass-edit-panel .content_menu .icheckbox_minimal-blue {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
#mass-edit-panel .icheckbox_minimal-blue {
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
}
|
||||
</style>
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="/libraries/grid/plugins/icheck/skins/minimal/minimal.css">
|
||||
<link rel="stylesheet" type="text/css" href="/libraries/grid/plugins/icheck/skins/minimal/blue.css">
|
||||
|
||||
<div class="panel mb50 panel-primary" id="mass-edit-panel">
|
||||
<div class="panel-heading">
|
||||
<span class="panel-title">Masowa edycja produktów</span>
|
||||
</div>
|
||||
@@ -8,7 +60,7 @@
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div class="form-group mb10">
|
||||
<label class="col-lg-3 control-label" for="inputDefault">Ustaw cenę promocyjną (minus X procent)</label>
|
||||
<label class="col-lg-3 control-label" for="discount_percent">Ustaw cenę promocyjną (minus X procent)</label>
|
||||
<div class="col-lg-9">
|
||||
<div class="bs-component">
|
||||
<div class="input-group">
|
||||
@@ -24,200 +76,39 @@
|
||||
<div class="panel-body">
|
||||
<div class="row">
|
||||
<div class="col-lg-6">
|
||||
<? foreach ( $this -> products as $key => $product ):?>
|
||||
<div class="checkbox-custom fill mb5">
|
||||
<input type="checkbox" name="products[]" id="product<?= $key;?>" value="<?= $key;?>">
|
||||
<label for="product<?= $key;?>"><?= $product;?></label>
|
||||
<?php if ( is_array( $this->products ) ): foreach ( $this->products as $key => $product ): ?>
|
||||
<div class="product-item">
|
||||
<input type="checkbox" class="g-checkbox" name="products[]" id="product<?= $key; ?>" value="<?= $key; ?>">
|
||||
<label for="product<?= $key; ?>"><?= htmlspecialchars( $product ); ?></label>
|
||||
</div>
|
||||
<? endforeach;?>
|
||||
<?php endforeach; endif; ?>
|
||||
</div>
|
||||
<div class="col-lg-6">
|
||||
<div class="menu_sortable">
|
||||
<ol class="sortable" id="sortable">
|
||||
<? if ( is_array( $this -> categories ) ): foreach ( $this -> categories as $category ):?>
|
||||
<li id="list_<?= $category['id'];?>" class="category_<?= $category['id'];?>" category="<?= $category['id'];?>">
|
||||
<?php if ( is_array( $this->categories ) ): foreach ( $this->categories as $category ): ?>
|
||||
<li id="list_<?= $category['id']; ?>" class="category_<?= $category['id']; ?>" category="<?= $category['id']; ?>">
|
||||
<div class="context_0 content content_menu">
|
||||
<span class="disclose"><span></span></span>
|
||||
<? if ( !$category['status'] ) echo '<i class="fa fa-ban fa-lg text-danger" title="Kategoria nieaktywna"></i>';?>
|
||||
<b><?= $category['languages'][$this -> dlang]['title'];?></b>
|
||||
<button type="button" class="disclose layout-tree-toggle" aria-expanded="false" title="Rozwin / zwin">
|
||||
<i class="fa fa-caret-right"></i>
|
||||
</button>
|
||||
<?php if ( !$category['status'] ) echo '<i class="fa fa-ban fa-lg text-danger" title="Kategoria nieaktywna"></i>'; ?>
|
||||
<input type="checkbox" class="g-checkbox" name="mass_categories[]" value="<?= $category['id']; ?>" />
|
||||
<b><?= $category['languages'][$this->dlang]['title']; ?></b>
|
||||
</div>
|
||||
<?= \Tpl::view( 'shop-product/subcategories-list', [
|
||||
'categories' => \admin\factory\ShopCategory::subcategories( $category['id'] ),
|
||||
'level' => $this -> level + 1,
|
||||
'dlang' => $this -> dlang
|
||||
] );?>
|
||||
'level' => ($this->level ?? 0) + 1,
|
||||
'dlang' => $this->dlang,
|
||||
'name' => 'mass_categories[]'
|
||||
] ); ?>
|
||||
</li>
|
||||
<? endforeach; endif;?>
|
||||
<?php endforeach; endif; ?>
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript" src="/libraries/jquery-nested-sortable/jquery.mjs.nestedSortable.js"></script>
|
||||
<script type="text/javascript">
|
||||
$( document ).ready( function()
|
||||
{
|
||||
$( 'ol.sortable' ).nestedSortable(
|
||||
{
|
||||
forcePlaceholderSize: true,
|
||||
handle: 'div',
|
||||
helper: 'clone',
|
||||
items: 'li',
|
||||
opacity: .9,
|
||||
placeholder: 'placeholder',
|
||||
revert: 250,
|
||||
tabSize: 45,
|
||||
tolerance: 'pointer',
|
||||
toleranceElement: '> div',
|
||||
maxLevels: 4,
|
||||
isTree: true,
|
||||
expandOnHover: 700,
|
||||
protectRoot: false
|
||||
});
|
||||
|
||||
$( '.disclose' ).on( 'click', function()
|
||||
{
|
||||
$( this ).closest( 'li' ).toggleClass( 'sort-collapsed' ).toggleClass( 'sort-expanded' );
|
||||
});
|
||||
|
||||
$( '.disclose' ).mousedown( function(e) {
|
||||
if ( e.which === 1 ) {
|
||||
var category_id = $( this ).parent( 'div' ).parent( 'li' ).attr( 'id' );
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/ajax.php',
|
||||
data: {
|
||||
a: 'cookie_categories',
|
||||
category_id: category_id
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
<?php
|
||||
$array = unserialize( $_COOKIE[ 'cookie_categories' ] );
|
||||
if ( is_array( $array ) ): foreach ( $array as $key => $val ):
|
||||
if ( $val ):
|
||||
?>$( '#<?= $key;?>' ).children( 'div' ).children( 'span.disclose' ).click();<?
|
||||
endif;
|
||||
endforeach; endif;
|
||||
?>
|
||||
|
||||
$( '.select-all' ).click( function()
|
||||
{
|
||||
$( '.checkbox-custom input' ).prop( 'checked', true );
|
||||
});
|
||||
|
||||
$( '.deselect-all' ).click( function()
|
||||
{
|
||||
$( '.checkbox-custom input' ).prop( 'checked', false );
|
||||
});
|
||||
|
||||
$( 'body' ).on( 'click', '#sortable input[type="checkbox"]', function(){
|
||||
if ( $( this ).is( ':checked' ) ) {
|
||||
$.ajax({
|
||||
url: '/admin/shop_product/get_products_by_category/',
|
||||
type: 'post',
|
||||
data: {
|
||||
category_id: $( this ).val()
|
||||
},
|
||||
success: function(data) {
|
||||
data = JSON.parse(data);
|
||||
if ( data.status == 'ok' ) {
|
||||
$.each( data.products, function( key, value ) {
|
||||
$( '#product' + value ).prop( 'checked', true );
|
||||
});
|
||||
}
|
||||
}
|
||||
})
|
||||
} else {
|
||||
$.ajax({
|
||||
url: '/admin/shop_product/get_products_by_category/',
|
||||
type: 'post',
|
||||
data: {
|
||||
category_id: $( this ).val()
|
||||
},
|
||||
success: function(data) {
|
||||
data = JSON.parse(data);
|
||||
if ( data.status == 'ok' ) {
|
||||
$.each( data.products, function( key, value ) {
|
||||
$( '#product' + value ).prop( 'checked', false );
|
||||
});
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
$( 'body' ).on( 'click', 'span[field-id="discount_percent"]', function()
|
||||
{
|
||||
$( '.ajax-msg' ).remove();
|
||||
var discount_percent = $( '#discount_percent' ).val();
|
||||
var products = [];
|
||||
$( 'input[name="products[]"]:checked' ).each( function(){
|
||||
products.push( $( this ).val() );
|
||||
});
|
||||
|
||||
function saveProduct(index) {
|
||||
if (index < products.length) {
|
||||
$.ajax({
|
||||
url: '/admin/shop_product/mass_edit_save/',
|
||||
type: 'post',
|
||||
data: {
|
||||
discount_percent: discount_percent,
|
||||
products: [products[index]]
|
||||
},
|
||||
success: function(data) {
|
||||
data = JSON.parse(data);
|
||||
if ( data.status == 'ok') {
|
||||
if ( data.price_brutto_promo )
|
||||
$( 'label[for="product' + products[index] + '"]' ).append( ' <span class="ajax-msg text-success">cena promocyjna: ' + data.price_brutto_promo + ' zł, cena zwykła: ' + data.price_brutto + '</span>' );
|
||||
else
|
||||
$( 'label[for="product' + products[index] + '"]' ).append( ' <span class="ajax-msg text-success">cena zwykła: ' + data.price_brutto + '</span>' );
|
||||
} else {
|
||||
alert('Błąd przy zapisie produktu: ', products[index]);
|
||||
}
|
||||
// Wywołanie dla następnego produktu
|
||||
saveProduct(index + 1);
|
||||
},
|
||||
error: function(err) {
|
||||
alert('Błąd przy zapisie produktu: ', err);
|
||||
// Można dodać obsługę błędu lub przerwać proces
|
||||
}
|
||||
});
|
||||
} else {
|
||||
$.alert({
|
||||
title: 'Informacja',
|
||||
content: 'Zakończono zapisywanie produktów',
|
||||
type: 'orange',
|
||||
closeIcon: true,
|
||||
closeIconClass: 'fa fa-close',
|
||||
typeAnimated: true,
|
||||
animation: 'opacity',
|
||||
autoClose: 'confirm|10000',
|
||||
useBootstrap: false,
|
||||
theme: 'modern',
|
||||
autoClose: 'cancel|10000',
|
||||
icon: 'fa fa-exclamation',
|
||||
buttons:
|
||||
{
|
||||
confirm:
|
||||
{
|
||||
text: 'Zamknij',
|
||||
btnClass: 'btn-blue',
|
||||
keys: ['enter'],
|
||||
action: function() {}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
if (products.length > 0) {
|
||||
saveProduct(0); // Rozpoczęcie od pierwszego produktu
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<?= \Tpl::view( 'shop-product/mass-edit-custom-script' ); ?>
|
||||
|
||||
@@ -3,7 +3,9 @@
|
||||
<? foreach ( $this -> categories as $category ):?>
|
||||
<li id="list_<?= $category[ 'id' ];?>" class="list_<?= $category[ 'id' ];?>" category="<?= $category[ 'id' ];?>">
|
||||
<div class="context_0 content content_menu">
|
||||
<span class="disclose"><span></span></span>
|
||||
<button type="button" class="disclose layout-tree-toggle" aria-expanded="false" title="Rozwin / zwin">
|
||||
<i class="fa fa-caret-right"></i>
|
||||
</button>
|
||||
<? if ( !$category[ 'status' ] ) echo '<i class="fa fa-ban fa-lg text-danger" title="Kategoria nieaktywna"></i>';?>
|
||||
<input type="checkbox" class="g-checkbox" name="<?= $this -> name ? $this -> name : 'categories[]';?>" value="<?= $category[ 'id' ];?>" <? if ( is_array( $this -> product_categories ) and in_array( $category[ 'id' ], $this -> product_categories ) ):?>checked="checked"<? endif;?> />
|
||||
<b><?= $category[ 'languages' ][ $this -> dlang ][ 'title' ];?></b>
|
||||
|
||||
Reference in New Issue
Block a user