refactor(shop-coupon): migrate admin module to DI and release 0.266
This commit is contained in:
@@ -7,6 +7,48 @@
|
||||
<script type="text/javascript" src="/libraries/codemirror/mode/javascript/javascript.js"></script>
|
||||
<script type="text/javascript" src="/libraries/codemirror/mode/htmlmixed/htmlmixed.js"></script>
|
||||
<script type="text/javascript" src="/libraries/codemirror/addon/mode/multiplex.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);
|
||||
}
|
||||
|
||||
#fg-layout-edit input[type=checkbox].g-checkbox {
|
||||
-webkit-appearance: checkbox;
|
||||
appearance: auto;
|
||||
position: static;
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
background: initial;
|
||||
border-radius: 0;
|
||||
box-shadow: none;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
#fg-layout-edit input[type=checkbox].g-checkbox:before {
|
||||
content: none;
|
||||
}
|
||||
</style>
|
||||
<script type="text/javascript">
|
||||
$( function()
|
||||
{
|
||||
@@ -76,9 +118,43 @@
|
||||
}
|
||||
});
|
||||
|
||||
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();
|
||||
|
||||
$( '.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)
|
||||
@@ -116,21 +192,39 @@
|
||||
});
|
||||
|
||||
<?php
|
||||
$array = unserialize( $_COOKIE[ 'cookie_pages' ] );
|
||||
if ( is_array( $array ) ): foreach ( $array as $key => $val ):
|
||||
if ( $val ):
|
||||
?>$( '.<?= $key;?>' ).children( 'div' ).children( 'span.disclose' ).click();<?
|
||||
endif;
|
||||
endforeach; endif;
|
||||
$cookiePages = [];
|
||||
$cookieMenus = [];
|
||||
|
||||
$array = unserialize( $_COOKIE[ 'cookie_menus' ] );
|
||||
if ( is_array( $array ) ): foreach ( $array as $key => $val ):
|
||||
if ( $val ):
|
||||
?>$( '.menu_<?= $key;?>' ).children( 'div' ).children( 'span.disclose' ).click();<?
|
||||
endif;
|
||||
endforeach; endif;
|
||||
if ( !empty( $_COOKIE['cookie_pages'] ) )
|
||||
{
|
||||
$decoded = @unserialize( (string)$_COOKIE['cookie_pages'], [ 'allowed_classes' => false ] );
|
||||
if ( is_array( $decoded ) )
|
||||
$cookiePages = $decoded;
|
||||
}
|
||||
|
||||
if ( !empty( $_COOKIE['cookie_menus'] ) )
|
||||
{
|
||||
$decoded = @unserialize( (string)$_COOKIE['cookie_menus'], [ 'allowed_classes' => false ] );
|
||||
if ( is_array( $decoded ) )
|
||||
$cookieMenus = $decoded;
|
||||
}
|
||||
?>
|
||||
|
||||
var cookiePages = <?= json_encode( $cookiePages, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES );?>;
|
||||
var cookieMenus = <?= json_encode( $cookieMenus, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES );?>;
|
||||
|
||||
Object.keys( cookiePages || {} ).forEach( function( key )
|
||||
{
|
||||
if ( String( cookiePages[key] ) === '1' && /^\d+$/.test( String( key ) ) )
|
||||
$( '.list_' + key ).children( 'div' ).children( '.disclose' ).click();
|
||||
});
|
||||
|
||||
Object.keys( cookieMenus || {} ).forEach( function( key )
|
||||
{
|
||||
if ( String( cookieMenus[key] ) === '1' && /^\d+$/.test( String( key ) ) )
|
||||
$( '.menu_' + key ).children( 'div' ).children( '.disclose' ).click();
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
<?
|
||||
@@ -177,7 +271,9 @@ ob_start();
|
||||
<ol class="sortable" id="sortable_<?= $menu['id'];?>">
|
||||
<li id="list_<?= $menu['id'];?>" class="menu_<?= $menu['id'];?>" menu="<?= $menu['id'];?>">
|
||||
<div class="context_0 content content_menu" <? if ( !$menu['status'] ) echo 'style="color: #cc0000;"';?>>
|
||||
<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>
|
||||
Menu: <b><?= $menu['name'];?></b>
|
||||
</div>
|
||||
<?= \Tpl::view( 'layouts/subpages-list', [
|
||||
@@ -199,7 +295,9 @@ ob_start();
|
||||
<? 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>
|
||||
<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="categories[]" value="<?= $category['id'];?>" <? if ( is_array( $this -> layout['categories'] ) and in_array( $category['id'], $this -> layout['categories'] ) ):?>checked="checked"<? endif;?> />
|
||||
<b><?= $category['languages'][$this -> dlang]['title'];?></b>
|
||||
|
||||
@@ -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="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>
|
||||
@@ -17,4 +19,3 @@
|
||||
<? endforeach;?>
|
||||
</ol>
|
||||
<? endif;?>
|
||||
|
||||
|
||||
@@ -3,7 +3,9 @@
|
||||
<? foreach ( $this -> pages as $page ):?>
|
||||
<li id="list_<?= $page['id'];?>" idk="<?= $page['id'];?>" class="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>
|
||||
<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[]" value="<?= $page['id'];?>" <? if ( is_array( $this -> layout_pages ) and in_array( $page['id'], $this -> layout_pages ) ):?>checked="checked"<? endif;?> /><?= $page['title'];?>
|
||||
</div>
|
||||
<?
|
||||
|
||||
19
admin/templates/shop-coupon/coupon-categories-selector.php
Normal file
19
admin/templates/shop-coupon/coupon-categories-selector.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
$label = trim((string)($this->label ?? 'Kategorie'));
|
||||
$inputName = trim((string)($this->inputName ?? 'categories[]'));
|
||||
$categories = is_array($this->categories ?? null) ? $this->categories : [];
|
||||
$selectedIds = is_array($this->selectedIds ?? null) ? $this->selectedIds : [];
|
||||
?>
|
||||
<div class="form-group row js-coupon-row js-coupon-row-categories">
|
||||
<label class="col-lg-4 control-label"><?= htmlspecialchars($label, ENT_QUOTES, 'UTF-8'); ?>:</label>
|
||||
<div class="col-lg-8">
|
||||
<div class="coupon-categories-box">
|
||||
<?= \Tpl::view('shop-coupon/coupon-categories-tree', [
|
||||
'categories' => $categories,
|
||||
'selectedIds' => $selectedIds,
|
||||
'inputName' => $inputName,
|
||||
]); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
68
admin/templates/shop-coupon/coupon-categories-tree.php
Normal file
68
admin/templates/shop-coupon/coupon-categories-tree.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
$categories = is_array($this->categories ?? null) ? $this->categories : [];
|
||||
$inputName = trim((string)($this->inputName ?? 'categories[]'));
|
||||
$selectedRaw = is_array($this->selectedIds ?? null) ? $this->selectedIds : [];
|
||||
$selected = [];
|
||||
foreach ($selectedRaw as $value) {
|
||||
$id = (int)$value;
|
||||
if ($id > 0) {
|
||||
$selected[$id] = true;
|
||||
}
|
||||
}
|
||||
?>
|
||||
<?php if (!empty($categories)): ?>
|
||||
<ol class="coupon-categories-tree">
|
||||
<?php foreach ($categories as $category): ?>
|
||||
<?php
|
||||
$categoryId = (int)($category['id'] ?? 0);
|
||||
if ($categoryId <= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$title = trim((string)($category['title'] ?? ''));
|
||||
if ($title === '') {
|
||||
$title = 'Kategoria #' . $categoryId;
|
||||
}
|
||||
|
||||
$isActive = (int)($category['status'] ?? 0) === 1;
|
||||
$children = is_array($category['subcategories'] ?? null) ? $category['subcategories'] : [];
|
||||
$hasChildren = !empty($children);
|
||||
?>
|
||||
<li class="coupon-category-item<?= $hasChildren ? ' has-children is-collapsed' : ''; ?>">
|
||||
<div class="coupon-category-row">
|
||||
<?php if ($hasChildren): ?>
|
||||
<button type="button" class="coupon-tree-toggle" aria-expanded="false" title="Rozwin / zwin">
|
||||
<i class="fa fa-caret-right"></i>
|
||||
</button>
|
||||
<?php else: ?>
|
||||
<span class="coupon-tree-spacer"></span>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (!$isActive): ?>
|
||||
<i class="fa fa-ban text-danger" title="Kategoria nieaktywna"></i>
|
||||
<?php endif; ?>
|
||||
|
||||
<label class="coupon-category-label">
|
||||
<input
|
||||
type="checkbox"
|
||||
class="g-checkbox"
|
||||
name="<?= htmlspecialchars($inputName, ENT_QUOTES, 'UTF-8'); ?>"
|
||||
value="<?= $categoryId; ?>"
|
||||
<?= isset($selected[$categoryId]) ? 'checked="checked"' : ''; ?>
|
||||
/>
|
||||
<span><?= htmlspecialchars($title, ENT_QUOTES, 'UTF-8'); ?></span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<?php if ($hasChildren): ?>
|
||||
<?= \Tpl::view('shop-coupon/coupon-categories-tree', [
|
||||
'categories' => $children,
|
||||
'selectedIds' => array_keys($selected),
|
||||
'inputName' => $inputName,
|
||||
]); ?>
|
||||
<?php endif; ?>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ol>
|
||||
<?php endif; ?>
|
||||
|
||||
109
admin/templates/shop-coupon/coupon-edit-custom-script.php
Normal file
109
admin/templates/shop-coupon/coupon-edit-custom-script.php
Normal file
@@ -0,0 +1,109 @@
|
||||
<style type="text/css">
|
||||
.coupon-categories-box {
|
||||
max-height: 420px;
|
||||
overflow: auto;
|
||||
border: 1px solid #d6d6d6;
|
||||
border-radius: 4px;
|
||||
padding: 8px 10px;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.coupon-categories-tree {
|
||||
margin: 0;
|
||||
padding: 0 0 0 16px;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.coupon-category-item {
|
||||
margin: 2px 0;
|
||||
}
|
||||
|
||||
.coupon-category-item.is-collapsed > ol {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.coupon-category-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
min-height: 28px;
|
||||
}
|
||||
|
||||
.coupon-tree-toggle,
|
||||
.coupon-tree-spacer {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.coupon-tree-toggle {
|
||||
cursor: pointer;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.coupon-tree-toggle:focus,
|
||||
.coupon-tree-toggle:active,
|
||||
.coupon-tree-toggle:focus-visible {
|
||||
outline: none;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.coupon-category-item:not(.is-collapsed) > .coupon-category-row .coupon-tree-toggle i {
|
||||
transform: rotate(90deg);
|
||||
}
|
||||
|
||||
.coupon-category-label {
|
||||
margin: 0;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.coupon-category-row .icheckbox_minimal-blue {
|
||||
margin-top: 0;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script type="text/javascript">
|
||||
(function($) {
|
||||
if (!$) {
|
||||
return;
|
||||
}
|
||||
|
||||
$(document).off('click.shopCouponTree', '.coupon-tree-toggle');
|
||||
$(document).on('click.shopCouponTree', '.coupon-tree-toggle', function(e) {
|
||||
e.preventDefault();
|
||||
var $item = $(this).closest('.coupon-category-item');
|
||||
$item.toggleClass('is-collapsed');
|
||||
$(this).attr('aria-expanded', $item.hasClass('is-collapsed') ? 'false' : 'true');
|
||||
this.blur();
|
||||
});
|
||||
|
||||
function initCouponCategoryCheckboxes() {
|
||||
if (!$.fn || typeof $.fn.iCheck !== 'function') {
|
||||
return;
|
||||
}
|
||||
|
||||
$('.coupon-categories-box .g-checkbox').each(function() {
|
||||
var $checkbox = $(this);
|
||||
if ($checkbox.parent().hasClass('icheckbox_minimal-blue')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$checkbox.iCheck({
|
||||
checkboxClass: 'icheckbox_minimal-blue',
|
||||
radioClass: 'iradio_minimal-blue'
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
initCouponCategoryCheckboxes();
|
||||
})(window.jQuery);
|
||||
</script>
|
||||
3
admin/templates/shop-coupon/coupon-edit-new.php
Normal file
3
admin/templates/shop-coupon/coupon-edit-new.php
Normal file
@@ -0,0 +1,3 @@
|
||||
<?= \Tpl::view('components/form-edit', ['form' => $this->form]); ?>
|
||||
<?= \Tpl::view('shop-coupon/coupon-edit-custom-script'); ?>
|
||||
|
||||
@@ -1,151 +0,0 @@
|
||||
<script type="text/javascript" src="/libraries/framework/vendor/plugins/ckeditor/ckeditor.js"></script>
|
||||
<script type="text/javascript" src="/libraries/framework/vendor/plugins/ckeditor/adapters/jquery.js"></script>
|
||||
<script type="text/javascript" src="/libraries/jquery/sortable/sortable.js"></script>
|
||||
<?
|
||||
global $db;
|
||||
|
||||
ob_start();
|
||||
?>
|
||||
<div id="settings-tabs">
|
||||
<ul class="resp-tabs-list settings-tabs">
|
||||
<li><i class="fa fa-wrench"></i>Ustawienia</li>
|
||||
</ul>
|
||||
<div class="resp-tabs-container settings-tabs">
|
||||
<div>
|
||||
<?= \Html::input([
|
||||
'label' => 'Nazwa',
|
||||
'name' => 'name',
|
||||
'id' => 'name',
|
||||
'value' => $this -> coupon['name']
|
||||
]); ?>
|
||||
<?= \Html::input_switch([
|
||||
'label' => 'Wysłany',
|
||||
'name' => 'send',
|
||||
'checked' => $this -> coupon['send'] == 1 ? true : false
|
||||
]); ?>
|
||||
<?= \Html::input_switch([
|
||||
'label' => 'Aktywny',
|
||||
'name' => 'status',
|
||||
'checked' => $this -> coupon['status'] == 1 ? true : false
|
||||
]); ?>
|
||||
<?= \Html::input_switch( [
|
||||
'label' => 'Użyty',
|
||||
'name' => 'used',
|
||||
'checked' => $this -> coupon['used'] == 1 ? true : false,
|
||||
]); ?>
|
||||
<?= \Html::select([
|
||||
'label' => 'Typ kuponu',
|
||||
'name' => 'type',
|
||||
'values' => [ 1 => 'Rabat procentowy na koszyk'],
|
||||
'value' => $this -> coupo['type'],
|
||||
]); ?>
|
||||
<?= \Html::input([
|
||||
'label' => 'Wartość',
|
||||
'class' => 'number-format',
|
||||
'name' => 'amount',
|
||||
'id' => 'amount',
|
||||
'value' => $this -> coupon['amount']
|
||||
]); ?>
|
||||
<?= \Html::input_switch([
|
||||
'label' => 'Kupon jednorazowy',
|
||||
'name' => 'one_time',
|
||||
'checked' => $this -> coupon['one_time'] == 1 ? true : false
|
||||
]); ?>
|
||||
<?= \Html::input_switch([
|
||||
'label' => 'Dotyczy również produktów przecenionych',
|
||||
'name' => 'include_discounted_product',
|
||||
'checked' => $this -> coupon['include_discounted_product'] == 1 ? true : false,
|
||||
]); ?>
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-4 control-label">Ogranicz promocję do wybranych kategorii:</label>
|
||||
<div class="col-lg-8">
|
||||
<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' ];?>">
|
||||
<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>';?>
|
||||
<input type="checkbox" class="g-checkbox" name="categories[]" value="<?= $category[ 'id' ];?>" <? if ( is_array( json_decode( $this -> coupon['categories'] ) ) and in_array( $category[ 'id' ], json_decode( $this -> coupon['categories'] ) ) ):?>checked="checked"<? endif;?> />
|
||||
<b><?= $category[ 'languages' ][ $this -> dlang ][ 'title' ];?></b>
|
||||
</div>
|
||||
<?=
|
||||
\Tpl::view( 'shop-product/subcategories-list', [
|
||||
'categories' => \admin\factory\ShopCategory::subcategories( $category[ 'id' ] ),
|
||||
'product_categories' => json_decode( $this -> coupon['categories'] ),
|
||||
'dlang' => $this -> dlang
|
||||
] );
|
||||
?>
|
||||
</li>
|
||||
<?
|
||||
}
|
||||
}
|
||||
?>
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?
|
||||
$out = ob_get_clean();
|
||||
|
||||
$grid = new \gridEdit;
|
||||
$grid->id = 'coupon-edit';
|
||||
$grid->gdb_opt = $gdb;
|
||||
$grid->include_plugins = true;
|
||||
$grid->title = $this -> coupon['id'] ? 'Edycja kuponu: <u>' . $this -> coupon['name'] . '</u>' : 'Nowy kupon';
|
||||
$grid->fields = [
|
||||
[
|
||||
'db' => 'id',
|
||||
'type' => 'hidden',
|
||||
'value' => $this -> coupon['id']
|
||||
]
|
||||
];
|
||||
$grid->actions = [
|
||||
'save' => ['url' => '/admin/shop_coupon/coupon_save/', 'back_url' => '/admin/shop_coupon/view_list/'],
|
||||
'cancel' => ['url' => '/admin/shop_coupon/view_list/']
|
||||
];
|
||||
$grid->external_code = $out;
|
||||
$grid->persist_edit = true;
|
||||
$grid->id_param = 'id';
|
||||
|
||||
echo $grid->draw();
|
||||
?>
|
||||
|
||||
<link type="text/css" rel="stylesheet" href="/libraries/plupload/jquery.plupload.queue/css/jquery.plupload.queue.css">
|
||||
<link type="text/css" rel="stylesheet" href="/libraries/selectize/css/selectize.css">
|
||||
<link type="text/css" rel="stylesheet" href="/libraries/selectize/css/selectize.default.css">
|
||||
|
||||
<script type="text/javascript" src="/libraries/plupload/plupload.js"></script>
|
||||
<script type="text/javascript" src="/libraries/plupload/plupload.flash.js"></script>
|
||||
<script type="text/javascript" src="/libraries/plupload/plupload.html5.js"></script>
|
||||
<script type="text/javascript" src="/libraries/plupload/plupload.html4.js"></script>
|
||||
<script type="text/javascript" src="/libraries/plupload/jquery.plupload.queue/jquery.plupload.queue.js"></script>
|
||||
<script type="text/javascript" src="/libraries/plupload/i18n/pl.js"></script>
|
||||
<script type="text/javascript" src="/libraries/jquery-nested-sortable/jquery.mjs.nestedSortable.js"></script>
|
||||
<script type="text/javascript" src="/libraries/jquery/lozad.js"></script>
|
||||
<script type="text/javascript" src="/libraries/selectize/js/standalone/selectize.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(function() {
|
||||
const observer = lozad();
|
||||
observer.observe();
|
||||
|
||||
disable_menu();
|
||||
|
||||
$('#settings-tabs').easyResponsiveTabs({
|
||||
width: 'auto',
|
||||
fit: true,
|
||||
tabidentify: 'settings-tabs',
|
||||
type: 'vertical'
|
||||
});
|
||||
});
|
||||
</script>
|
||||
2
admin/templates/shop-coupon/coupons-list.php
Normal file
2
admin/templates/shop-coupon/coupons-list.php
Normal file
@@ -0,0 +1,2 @@
|
||||
<?= \Tpl::view('components/table-list', ['list' => $this->viewModel]); ?>
|
||||
|
||||
@@ -1,88 +0,0 @@
|
||||
<?php
|
||||
global $gdb;
|
||||
|
||||
$grid = new \grid( 'pp_shop_coupon' );
|
||||
$grid -> gdb_opt = $gdb;
|
||||
$grid -> debug = true;
|
||||
$grid -> order = [ 'column' => 'name', 'type' => 'ASC' ];
|
||||
$grid -> search = [
|
||||
[ 'name' => 'Nazwa', 'db' => 'name', 'type' => 'text' ],
|
||||
[ 'name' => 'Aktywny', 'db' => 'status', 'type' => 'select', 'replace' => [ 'array' => [ 0 => 'nie', 1 => 'tak' ] ] ],
|
||||
[ 'name' => 'Użyty', 'db' => 'used', 'type' => 'select', 'replace' => [ 'array' => [ 0 => 'nie', 1 => 'tak' ] ] ],
|
||||
[ 'name' => 'Wysłany', 'db' => 'send', 'type' => 'select', 'replace' => [ 'array' => [ 0 => 'nie', 1 => 'tak' ] ] ]
|
||||
];
|
||||
$grid -> columns_view = [
|
||||
[
|
||||
'name' => 'Lp.',
|
||||
'th' => [ 'class' => 'g-lp' ],
|
||||
'td' => [ 'class' => 'g-center' ],
|
||||
'autoincrement' => true
|
||||
], [
|
||||
'name' => 'Aktywny',
|
||||
'db' => 'status',
|
||||
'replace' => [ 'array' => [ 0 => '<span style="color: #FF0000;">nie</span>', 1 => 'tak' ] ],
|
||||
'td' => [ 'class' => 'g-center' ],
|
||||
'th' => [ 'class' => 'g-center', 'style' => 'width: 150px;' ],
|
||||
'sort' => true
|
||||
], [
|
||||
'name' => 'Użyto X razy',
|
||||
'db' => 'used_count',
|
||||
'td' => [ 'class' => 'g-center' ],
|
||||
'th' => [ 'class' => 'g-center', 'style' => 'width: 150px;' ],
|
||||
], [
|
||||
'name' => 'Nazwa',
|
||||
'db' => 'name',
|
||||
'sort' => true,
|
||||
'php' => 'echo "<a href=\'/admin/shop_coupon/coupon_edit/id=[id]\'>[name]</a>";'
|
||||
], [
|
||||
'name' => 'Typ kuponu',
|
||||
'db' => 'type',
|
||||
'replace' => [ 'array' => [ 1 => 'Rabat procentowy na koszyk' ] ]
|
||||
], [
|
||||
'name' => 'Wartość',
|
||||
'db' => 'amount',
|
||||
'php' => 'if ( [type] == 1 ) echo "[amount]%";'
|
||||
], [
|
||||
'name' => 'Kupon jednorazowy',
|
||||
'db' => 'one_time',
|
||||
'replace' => [ 'array' => [ 0 => 'nie', 1 => 'tak' ] ],
|
||||
'td' => [ 'class' => 'g-center' ],
|
||||
'th' => [ 'class' => 'g-center', 'style' => 'width: 150px;' ]
|
||||
], [
|
||||
'name' => 'Wysłany',
|
||||
'db' => 'send',
|
||||
'replace' => [ 'array' => [ 0 => 'nie', 1 => 'tak' ] ],
|
||||
'td' => [ 'class' => 'g-center' ],
|
||||
'th' => [ 'class' => 'g-center', 'style' => 'width: 150px;' ]
|
||||
], [
|
||||
'name' => 'Użyty',
|
||||
'db' => 'used',
|
||||
'replace' => [ 'array' => [ 0 => 'nie', 1 => 'tak' ] ],
|
||||
'td' => [ 'class' => 'g-center' ],
|
||||
'th' => [ 'class' => 'g-center', 'style' => 'width: 150px;' ]
|
||||
], [
|
||||
'name' => 'Data użycia',
|
||||
'db' => 'date_used',
|
||||
'td' => [ 'class' => 'g-center' ],
|
||||
'th' => [ 'class' => 'g-center', 'style' => 'width: 150px;' ]
|
||||
], [
|
||||
'name' => 'Edytuj',
|
||||
'action' => [ 'type' => 'edit', 'url' => '/admin/shop_coupon/coupon_edit/id=[id]' ],
|
||||
'th' => [ 'class' => 'g-center', 'style' => 'width: 70px;' ],
|
||||
'td' => [ 'class' => 'g-center' ]
|
||||
], [
|
||||
'name' => 'Usuń',
|
||||
'action' => [ 'type' => 'delete', 'url' => '/admin/shop_coupon/coupon_delete/id=[id]' ],
|
||||
'th' => [ 'class' => 'g-center', 'style' => 'width: 70px;' ],
|
||||
'td' => [ 'class' => 'g-center' ]
|
||||
]
|
||||
];
|
||||
$grid -> buttons = [
|
||||
[
|
||||
'label' => 'Dodaj kupon',
|
||||
'url' => '/admin/shop_coupon/coupon_edit/',
|
||||
'icon' => 'fa-plus-circle',
|
||||
'class' => 'btn-success'
|
||||
]
|
||||
];
|
||||
echo $grid -> draw();
|
||||
@@ -75,7 +75,7 @@
|
||||
<li>
|
||||
<a href="/admin/shop_statuses/view_list/"><i class="fa fa-bars"></i>Statusy zamówień</a>
|
||||
</li>
|
||||
<li><a href="/admin/shop_coupon/view_list/"><img src="/admin/layout/icon/icon-menu/piggy-bank-coins.svg">Kody rabatowe</a></li>
|
||||
<li><a href="/admin/shop_coupon/list/"><img src="/admin/layout/icon/icon-menu/piggy-bank-coins.svg">Kody rabatowe</a></li>
|
||||
<li><a href="/admin/shop_promotion/list/"><img src="/admin/layout/icon/icon-menu/burst-sale.svg">Promocje</a></li>
|
||||
</ul>
|
||||
<div class="title">Zawartość</div>
|
||||
@@ -197,6 +197,55 @@
|
||||
</div>
|
||||
</div>
|
||||
<script class="footer" type="text/javascript">
|
||||
(function() {
|
||||
function bindClearCacheButton() {
|
||||
$(document)
|
||||
.off('click.clearCacheBtn', '#clear-cache-btn')
|
||||
.on('click.clearCacheBtn', '#clear-cache-btn', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
var $btn = $(this);
|
||||
var originalText = $btn.text();
|
||||
|
||||
// Show pending state
|
||||
$btn.prop('disabled', true).html('<i class="fa fa-spinner fa-spin"></i> Czyszcz\u0119 cache...');
|
||||
|
||||
// Send AJAX request
|
||||
$.ajax({
|
||||
url: '/admin/settings/clearCacheAjax/',
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
success: function(response) {
|
||||
if (response.status === 'success') {
|
||||
// Show success state
|
||||
$btn.html('<i class="fa fa-check"></i> Cache wyczyszczony!').removeClass('btn-danger').addClass('btn-success');
|
||||
|
||||
// Restore original state after delay
|
||||
setTimeout(function() {
|
||||
$btn.prop('disabled', false).html(originalText).removeClass('btn-success').addClass('btn-danger');
|
||||
}, 2000);
|
||||
} else {
|
||||
// Request failed on server
|
||||
$btn.html('<i class="fa fa-exclamation-triangle"></i> B\u0142\u0105d!').removeClass('btn-danger').addClass('btn-warning');
|
||||
setTimeout(function() {
|
||||
$btn.prop('disabled', false).html(originalText).removeClass('btn-warning').addClass('btn-danger');
|
||||
}, 2000);
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
// Network or transport error
|
||||
$btn.html('<i class="fa fa-exclamation-triangle"></i> B\u0142\u0105d po\u0142\u0105czenia!').removeClass('btn-danger').addClass('btn-warning');
|
||||
setTimeout(function() {
|
||||
$btn.prop('disabled', false).html(originalText).removeClass('btn-warning').addClass('btn-danger');
|
||||
}, 2000);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
bindClearCacheButton();
|
||||
})();
|
||||
|
||||
$(document).ready(function () {
|
||||
var user_agent = navigator.userAgent.toLowerCase();
|
||||
var click_event = user_agent.match(/(iphone|ipod|ipad)/) ? "touchend" : "click";
|
||||
@@ -218,47 +267,6 @@
|
||||
}
|
||||
});
|
||||
|
||||
// Cache clear button handler
|
||||
$('#clear-cache-btn').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
var $btn = $(this);
|
||||
var originalText = $btn.text();
|
||||
|
||||
// Show pending state
|
||||
$btn.prop('disabled', true).html('<i class="fa fa-spinner fa-spin"></i> Czyszcz\u0119 cache...');
|
||||
|
||||
// Send AJAX request
|
||||
$.ajax({
|
||||
url: '/admin/settings/clearCacheAjax/',
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
success: function(response) {
|
||||
if (response.status === 'success') {
|
||||
// Show success state
|
||||
$btn.html('<i class="fa fa-check"></i> Cache wyczyszczony!').removeClass('btn-danger').addClass('btn-success');
|
||||
|
||||
// Restore original state after delay
|
||||
setTimeout(function() {
|
||||
$btn.prop('disabled', false).html(originalText).removeClass('btn-success').addClass('btn-danger');
|
||||
}, 2000);
|
||||
} else {
|
||||
// Request failed on server
|
||||
$btn.html('<i class="fa fa-exclamation-triangle"></i> B\u0142\u0105d!').removeClass('btn-danger').addClass('btn-warning');
|
||||
setTimeout(function() {
|
||||
$btn.prop('disabled', false).html(originalText).removeClass('btn-warning').addClass('btn-danger');
|
||||
}, 2000);
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
// Network or transport error
|
||||
$btn.html('<i class="fa fa-exclamation-triangle"></i> B\u0142\u0105d po\u0142\u0105czenia!').removeClass('btn-danger').addClass('btn-warning');
|
||||
setTimeout(function() {
|
||||
$btn.prop('disabled', false).html(originalText).removeClass('btn-warning').addClass('btn-danger');
|
||||
}, 2000);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user