first commit
This commit is contained in:
55
admin/templates/shop-attribute/_partials/value.php
Normal file
55
admin/templates/shop-attribute/_partials/value.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<div class="panel panel-widget draft-widget" value-number="<?= $this -> i;?>">
|
||||
<div class="panel-heading with-buttons">
|
||||
<span class="panel-title">Wartość <?= $this -> i;?></span>
|
||||
<div class="btn btn-danger btn-value-remove">
|
||||
<i class="fa fa-trash"></i> Usuń wartość
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel-body p20">
|
||||
<div class="row">
|
||||
<div class="col-lg-6">
|
||||
<div class="mb20">
|
||||
<input type="radio" id="default_value<?=$this -> value['id'];?>" name="default_value" value="<?= ( $this -> i - 1 );?>" <? if ( $this -> value['is_default'] ):?>checked<? endif;?>>
|
||||
<label for="default_value<?=$this -> value['id'];?>">Wartość domyślna</label>
|
||||
</div>
|
||||
<div class="row form-group">
|
||||
<div class="col-xs-8">
|
||||
<div class="input-group">
|
||||
<input class="form-control" name="impact_on_the_price[]" type="text" value="<?= $this -> value['impact_on_the_price'];?>" placeholder="wpływ na cenę produktu...">
|
||||
<span class="input-group-addon">
|
||||
<i class="fa fa-usd"></i>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-6">
|
||||
<div class="tab-block mb25">
|
||||
<ul class="nav nav-tabs nav-tabs-right tabs-border">
|
||||
<? $z = 0;?>
|
||||
<? if ( is_array( $this -> languages ) ): foreach ( $this -> languages as $lg ):?>
|
||||
<? if ( $lg['status'] ):?>
|
||||
<li class="<? if ( !$z++ ):?>active<? endif;?>">
|
||||
<a href="#tab<?= $this -> i;?>_<?= $lg['id'];?>" data-toggle="tab" aria-expanded="true"><?= $lg['name'];?></a>
|
||||
</li>
|
||||
<? endif;?>
|
||||
<? endforeach; endif;?>
|
||||
</ul>
|
||||
<div class="tab-content">
|
||||
<? $z = 0;?>
|
||||
<? if ( is_array( $this -> languages ) ): foreach ( $this -> languages as $lg ):?>
|
||||
<? if ( $lg['status'] ):?>
|
||||
<div id="tab<?= $this -> i;?>_<?= $lg['id'];?>" class="tab-pane <? if ( !$z++ ):?>active<? endif;?>">
|
||||
<? if ( $this -> attribute['type'] == 0 ):?>
|
||||
<input type="hidden" name="ids[<?= $lg['id'];?>][]" value="<?= $this -> value['id'];?>" />
|
||||
<input type="text" class="name-<?= $i;?> form-control" name="name[<?= $lg['id'];?>][]" value="<?= $this -> value['languages'][$lg['id']]['name'];?>">
|
||||
<? endif;?>
|
||||
</div>
|
||||
<? endif;?>
|
||||
<? endforeach; endif;?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
106
admin/templates/shop-attribute/attribute-edit.php
Normal file
106
admin/templates/shop-attribute/attribute-edit.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<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>
|
||||
<?php
|
||||
global $db;
|
||||
ob_start();
|
||||
?>
|
||||
<div id="settings-tabs">
|
||||
<ul class="resp-tabs-list settings-tabs">
|
||||
<li><i class="fa fa-file"></i>Treść</li>
|
||||
<li><i class="fa fa-wrench"></i>Ustawienia</li>
|
||||
</ul>
|
||||
<div class="resp-tabs-container settings-tabs">
|
||||
<div>
|
||||
<div id="languages-main">
|
||||
<ul class="resp-tabs-list languages-main htabs">
|
||||
<?php if (is_array($this -> languages)) : foreach ($this -> languages as $lg) : ?>
|
||||
<?php if ($lg['status']) : ?>
|
||||
<li><?php echo $lg['name']; ?></a></li>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; endif; ?>
|
||||
</ul>
|
||||
<div class="resp-tabs-container languages-main">
|
||||
<?php if (is_array($this -> languages)) : foreach ($this -> languages as $lg) : ?>
|
||||
<?php if ($lg['status']) : ?>
|
||||
<div>
|
||||
<?= \Html::input( [
|
||||
'label' => 'Tytuł',
|
||||
'name' => 'name[' . $lg['id'] . ']',
|
||||
'id' => 'name_' . $lg['id'],
|
||||
'value' => $this -> attribute['languages'][ $lg['id'] ]['name'],
|
||||
'inline' => true,
|
||||
] ); ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; endif; ?>
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<?= \Html::input_switch( [
|
||||
'label' => 'Aktywny',
|
||||
'name' => 'status',
|
||||
'checked' => $this -> attribute['status'] || !$this -> attribute['id'] ? true : false,
|
||||
] );?>
|
||||
<?= \Html::select( [
|
||||
'label' => 'Typ',
|
||||
'name' => 'type',
|
||||
'values' => [0 => 'tekst'],//, 1 => 'kolor', 2 => 'wzór'],
|
||||
'value' => $this -> attribute['type'],
|
||||
] );?>
|
||||
<?= \Html::input( [
|
||||
'label' => 'Kolejność',
|
||||
'name' => 'o',
|
||||
'id' => 'o',
|
||||
'value' => $this -> attribute['o'],
|
||||
] );?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
$out = ob_get_clean();
|
||||
|
||||
$grid = new \gridEdit();
|
||||
$grid -> id = 'attribute-edit';
|
||||
$grid -> gdb_opt = $gdb;
|
||||
$grid -> include_plugins = true;
|
||||
$grid -> title = 'Edycja cechy';
|
||||
$grid -> fields = [
|
||||
[
|
||||
'db' => 'id',
|
||||
'type' => 'hidden',
|
||||
'value' => $this -> attribute['id'],
|
||||
],
|
||||
];
|
||||
$grid -> actions = [
|
||||
'save' => ['url' => '/admin/shop_attribute/attribute_save/', 'back_url' => '/admin/shop_attribute/view_list/'],
|
||||
'cancel' => ['url' => '/admin/shop_attribute/view_list/'],
|
||||
];
|
||||
$grid -> external_code = $out;
|
||||
$grid -> persist_edit = true;
|
||||
$grid -> id_param = 'id';
|
||||
|
||||
echo $grid -> draw();
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
$( function()
|
||||
{
|
||||
disable_menu();
|
||||
|
||||
$( '#settings-tabs' ).easyResponsiveTabs({
|
||||
width: 'auto',
|
||||
fit: true,
|
||||
tabidentify: 'settings-tabs',
|
||||
type: 'vertical'
|
||||
});
|
||||
|
||||
$( '#languages-main' ).easyResponsiveTabs({
|
||||
width: 'auto',
|
||||
fit: true,
|
||||
tabidentify: 'languages-main'
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
<script>CKEDITOR.dtd.$removeEmpty['span'] = false;</script>
|
||||
95
admin/templates/shop-attribute/attributes-list.php
Normal file
95
admin/templates/shop-attribute/attributes-list.php
Normal file
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
|
||||
global $gdb;
|
||||
|
||||
$grid = new \grid('pp_shop_attributes');
|
||||
$grid -> gdb_opt = $gdb;
|
||||
$grid -> sql = 'SELECT *'
|
||||
. 'FROM ( '
|
||||
. 'SELECT '
|
||||
. 'id, status, type, o, '
|
||||
. '( SELECT psal.name FROM pp_shop_attributes_langs AS psal, pp_langs AS pl WHERE lang_id = pl.id AND attribute_id = psa.id AND psal.name != \'\' ORDER BY o ASC LIMIT 1 ) AS name '
|
||||
. 'FROM '
|
||||
. 'pp_shop_attributes AS psa '
|
||||
. ') AS q1 '
|
||||
. 'WHERE '
|
||||
. '1=1 [where] '
|
||||
. 'ORDER BY '
|
||||
. '[order_p1] [order_p2]';
|
||||
$grid -> sql_count = 'SELECT '
|
||||
. 'COUNT(0) FROM ( '
|
||||
. 'SELECT '
|
||||
. 'id, status, type, o, '
|
||||
. '( SELECT psal.name FROM pp_shop_attributes_langs AS psal, pp_langs AS pl WHERE lang_id = pl.id AND attribute_id = psa.id AND psal.name != \'\' ORDER BY o ASC LIMIT 1 ) AS name '
|
||||
. 'FROM '
|
||||
. 'pp_shop_attributes AS psa '
|
||||
. ') AS q1 '
|
||||
. 'WHERE '
|
||||
. '1=1 [where] ';
|
||||
$grid -> debug = true;
|
||||
$grid -> order = [ 'column' => 'o', 'type' => 'ASC' ];
|
||||
$grid -> search = [
|
||||
['name' => 'Nazwa', 'db' => 'name', 'type' => 'text'],
|
||||
['name' => 'Aktywny', 'db' => 'status', 'type' => 'select', 'replace' => ['array' => [0 => 'nie', 1 => 'tak']]],
|
||||
];
|
||||
$grid -> columns_view = [
|
||||
[
|
||||
'name' => 'Lp.',
|
||||
'th' => ['class' => 'g-lp'],
|
||||
'td' => ['class' => 'g-center'],
|
||||
'autoincrement' => true,
|
||||
],
|
||||
[
|
||||
'name' => 'Kolejność',
|
||||
'td' => [ 'class' => 'g-center', 'style' => 'width: 100px' ],
|
||||
'db' => 'o',
|
||||
'sort' => true,
|
||||
],
|
||||
[
|
||||
'name' => 'Nazwa',
|
||||
'db' => 'name',
|
||||
'php' => 'echo "<a href=\'/admin/shop_attribute/attribute_edit/id=[id]\'>[name]</a>";',
|
||||
'sort' => true,
|
||||
],
|
||||
[
|
||||
'name' => 'Typ',
|
||||
'db' => 'type',
|
||||
'replace' => ['array' => [0 => 'tekst', 1 => 'kolor', 2 => 'wzór']],
|
||||
'td' => ['class' => 'g-center'],
|
||||
'th' => ['class' => 'g-center', 'style' => 'width: 150px;'],
|
||||
'sort' => 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' => 'Wartości',
|
||||
'td' => ['class' => 'g-center'],
|
||||
'th' => ['class' => 'g-center', 'style' => 'width: 150px;'],
|
||||
'php' => 'echo "<a href=\'/admin/shop_attribute/values_edit/attribute-id=[id]\'>edytuj wartości</a>";',
|
||||
],
|
||||
[
|
||||
'name' => 'Edytuj',
|
||||
'action' => ['type' => 'edit', 'url' => '/admin/shop_attribute/attribute_edit/id=[id]'],
|
||||
'th' => ['class' => 'g-center', 'style' => 'width: 70px;'],
|
||||
'td' => ['class' => 'g-center'],
|
||||
],
|
||||
[
|
||||
'name' => 'Usuń',
|
||||
'action' => ['type' => 'delete', 'url' => '/admin/shop_attribute/delete_attribute/id=[id]'],
|
||||
'th' => ['class' => 'g-center', 'style' => 'width: 70px;'],
|
||||
'td' => ['class' => 'g-center'],
|
||||
],
|
||||
];
|
||||
$grid -> buttons = [
|
||||
[
|
||||
'label' => 'Dodaj cechę',
|
||||
'url' => '/admin/shop_attribute/attribute_edit/',
|
||||
'icon' => 'fa-plus-circle',
|
||||
'class' => 'btn-success',
|
||||
],
|
||||
];
|
||||
echo $grid -> draw();
|
||||
138
admin/templates/shop-attribute/values-edit.php
Normal file
138
admin/templates/shop-attribute/values-edit.php
Normal file
@@ -0,0 +1,138 @@
|
||||
<div class="panel panel-widget draft-widget" value-numer="<?= $this -> i;?>">
|
||||
<div class="panel-heading with-buttons">
|
||||
<span class="panel-title">Edycja wartości dla cechy: <?= $this -> attribute['languages']['pl']['name'];?></span>
|
||||
<div class="buttons">
|
||||
<a class="btn btn-success btn-save" href="#">
|
||||
<i class="fa fa-save"></i> zapisz
|
||||
</a>
|
||||
<a class="btn btn-dark" href="/admin/shop_attribute/view_list/">
|
||||
<i class="fa fa-ban"></i> wstecz
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel-body p20">
|
||||
<button class="btn btn-success mb10 btn-value-add">
|
||||
<i class="fa fa-plus-circle mr5"></i>Dodaj wartość
|
||||
</button>
|
||||
<div class="values-content">
|
||||
<?
|
||||
if ( $this -> values ):
|
||||
foreach ( $this -> values as $value ):
|
||||
echo \Tpl::view( 'shop-attribute/_partials/value', [
|
||||
'i' => ++$i,
|
||||
'value' => $value,
|
||||
'languages' => $this -> languages,
|
||||
'attribute' => $this -> attribute
|
||||
] );
|
||||
endforeach;
|
||||
endif;
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
$(function ()
|
||||
{
|
||||
disable_menu();
|
||||
|
||||
$( 'body' ).on( 'click', '.btn-save', function()
|
||||
{
|
||||
var values = jQuery( '.dashboard-page' ).find( 'input, select, textarea' ).serializeObject();
|
||||
|
||||
jQuery.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/shop_attribute/values_save/',
|
||||
data: {
|
||||
values: JSON.stringify( values ),
|
||||
attribute_id: <?= $this -> attribute['id'];?>,
|
||||
},
|
||||
beforeSend: function() {
|
||||
jQuery( '#overlay' ).show();
|
||||
},
|
||||
success: function( response ) {
|
||||
var data = jQuery.parseJSON( response );
|
||||
jQuery( '#overlay' ).hide();
|
||||
if ( data.status === 'ok' )
|
||||
{
|
||||
var msg = "Zapisano wartości atrybutu";
|
||||
alert_message( msg );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( data.msg )
|
||||
var msg = data.msg;
|
||||
else
|
||||
var msg = "Przepraszamy. Podczas wczytywania danych wystąpił błąd. Prosimy spróbować ponownie.";
|
||||
create_error( msg );
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$( 'body').on( 'click', '.btn-value-add', function ()
|
||||
{
|
||||
var maxVal = Math.max.apply(null, $('div[value-number]').map(function() {
|
||||
var val = parseInt($(this).attr('value-number'));
|
||||
return isNaN(val) ? 0 : val; // Jeżeli wartość nie jest liczbą, zwróć 0
|
||||
}).get());
|
||||
|
||||
if (!isFinite(maxVal)) {
|
||||
maxVal = 0;
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
url: '/admin/shop_attribute/attribute_value_tpl/',
|
||||
type: 'POST',
|
||||
data: {
|
||||
i: maxVal + 1,
|
||||
value: null,
|
||||
languages: <?= json_encode( $this -> languages );?>,
|
||||
attribute: <?= json_encode( $this -> attribute );?>
|
||||
},
|
||||
success: function( response )
|
||||
{
|
||||
$('.values-content').append(response);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$( 'body' ).on( 'click', '.btn-value-remove', function()
|
||||
{
|
||||
var button = $( this );
|
||||
$.alert({
|
||||
title: 'Potwierdź',
|
||||
content: 'Na pewno chcesz usunąć wybraną wartość?',
|
||||
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: 'TAK usuń',
|
||||
btnClass: 'btn-orange',
|
||||
keys: ['enter'],
|
||||
action: function()
|
||||
{
|
||||
button.closest( '.panel' ).remove();
|
||||
}
|
||||
},
|
||||
cancel:
|
||||
{
|
||||
text: 'anuluj',
|
||||
btnClass: 'btn-blue',
|
||||
action: function() {}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
Reference in New Issue
Block a user