This commit is contained in:
2026-03-28 11:33:56 +01:00
parent 412e235512
commit aa8e21862d
132 changed files with 24381 additions and 10882 deletions

View File

@@ -1,7 +1,7 @@
<div class="g-container" data="table:order-details">
<div class="panel panel-info panel-border top">
<div class="panel-heading">
<span class="panel-title">Kobinacje produktu: <?= $this -> product['languages'][ $this -> default_language ]['name'];?></span>
<span class="panel-title">Kombinacje produktu: <?= $this -> product['languages'][ $this -> default_language ]['name'];?></span>
</div>
<div class="panel-heading p10 pl15" id="g-menu" style="height: auto;">
<a class="btn btn btn-dark btn-sm mr5 btn-sm mr5" href="/admin/shop_product/view_list/"><i class="fa fa-reply mr5"></i>Wstecz</a>
@@ -13,53 +13,43 @@
<table class="table table-hover table-bordered table-condensed">
<thead>
<tr>
<th></th>
<th>Kombinacja</th>
<th>SKU</th>
<th>Stan magazynowy</th>
<th>Cena netto</th>
<th>Zam. SM 0</th>
<th>Baselinker</th>
<th>Zam. przy braku</th>
<th style="width: 100px;">Opcje</th>
</tr>
</thead>
<tbody>
<? if ( \S::is_array_fix( $this -> product_permutations ) ): foreach ( $this -> product_permutations as $product ):?>
<tr>
<td></td>
<? if ( \Shared\Helpers\Helpers::is_array_fix( $this -> product_permutations ) ): foreach ( $this -> product_permutations as $product ):?>
<tr data-combination-id="<?= $product['id'];?>">
<td>
<?
$attributes = explode( '|', $product['permutation_hash'] );
foreach ( $attributes as $attribute ):
$attribute_tmp = explode( '-', $attribute );
echo \admin\factory\ShopAttribute::get_attribute_name_by_id( $attribute_tmp[0] ) . ' - <b>' . \admin\factory\ShopAttribute::get_attribute_value_by_id( $attribute_tmp[1] ) . '</b>';
$attrRepo = new \Domain\Attribute\AttributeRepository( $GLOBALS['mdb'] );
echo $attrRepo->getAttributeNameById( (int)$attribute_tmp[0], $this -> default_language ) . ' - <b>' . $attrRepo->getAttributeValueById( (int)$attribute_tmp[1], $this -> default_language ) . '</b>';
if ( $attribute != end( $attributes ) )
echo ', ';
endforeach;
?>
</td>
<td>
<input type="text" name="sku" value="<?= $product['sku'];?>" class="form-control" style="max-width: 100px;" onchange="$.ajax({ type: 'POST', cache: false, url: '/admin/shop_product/product_combination_sku_save/', data: { product_id: <?= $product['id'];?>, sku: $( this ).val() } } );">
<input type="text" value="<?= $product['sku'];?>" class="form-control combination-field" style="max-width: 100px;" data-product-id="<?= $product['id'];?>" data-field="sku">
</td>
<td>
<input type="text" name="quantity" value="<?= $product['quantity'];?>" class="form-control" style="max-width: 100px;" onchange="$.ajax({ type: 'POST', cache: false, url: '/admin/shop_product/product_combination_quantity_save/', data: { product_id: <?= $product['id'];?>, quantity: $( this ).val() } } );">
<input type="text" value="<?= $product['quantity'];?>" class="form-control combination-field" style="max-width: 100px;" data-product-id="<?= $product['id'];?>" data-field="quantity">
</td>
<td>
<input type="text" name="price" value="<?= $product['price_netto'];?>" class="form-control" style="max-width: 100px;" onchange="$.ajax({ type: 'POST', cache: false, url: '/admin/shop_product/product_combination_price_save/', data: { product_id: <?= $product['id'];?>, price: $( this ).val() } } );">
<input type="text" value="<?= $product['price_netto'];?>" class="form-control combination-field" style="max-width: 100px;" data-product-id="<?= $product['id'];?>" data-field="price">
</td>
<td>
<input type="checkbox" name="stock_0_buy" <? if ( $product['stock_0_buy'] ): echo 'checked="checked"'; endif;?> onchange="$.ajax({ type: 'POST', cache: false, url: '/admin/shop_product/product_combination_stock_0_buy_save/', data: { product_id: <?= $product['id'];?>, stock_0_buy: $( this ).is( ':checked' ) } } );">
</td>
<td>
<?
if ( $product['baselinker_product_name'] != "" )
echo "<span title='" . $product['baselinker_product_name'] . "'>" . substr( $product['baselinker_product_name'], 0, 25 ) . "...</span>";
else
echo "<span class='text-danger baselinker-product-search' product-id='" . $product['id'] . "'>nie przypisano <i class='fa fa-search'></i></span>";
?>
<input type="checkbox" class="g-checkbox combination-checkbox" data-product-id="<?= $product['id'];?>" <? if ( $product['stock_0_buy'] ): echo 'checked="checked"'; endif;?>>
</td>
<td class="text-center">
<a href="/admin/shop_product/delete_combination/combination_id=<?= $product['id'];?>&product_id=<?= $product['parent_id'];?>" class="btn btn-danger btn-delete-permutation"><i class="fa fa-trash"></i></a>
<button type="button" class="btn btn-danger btn-delete-permutation" data-combination-id="<?= $product['id'];?>"><i class="fa fa-trash"></i></button>
</td>
</tr>
<? endforeach; endif;?>
@@ -74,6 +64,7 @@
<div class="combination-attribute">
<div class="title">
<?= $attribute['languages'][ $this -> default_language ]['name'];?>
<label style="float: right; font-weight: normal; font-size: 12px; cursor: pointer;"><input type="checkbox" class="g-checkbox select-all-attr"> wszystkie</label>
</div>
<ul class="values">
<? foreach ( $attribute['values'] as $value ):?>
@@ -90,9 +81,6 @@
</div>
</div>
</div>
<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">
<script type="text/javascript" src="/libraries/grid/plugins/icheck/icheck.min.js"></script>
<script type="text/javascript">
$( function()
{
@@ -101,10 +89,90 @@
radioClass: 'iradio_minimal-blue'
});
// "Zaznacz wszystkie" per atrybut
$( '.select-all-attr' ).on( 'ifChanged', function()
{
var checked = $( this ).is( ':checked' );
$( this ).closest( '.combination-attribute' ).find( '.g-checkbox' ).each( function()
{
$( this ).iCheck( checked ? 'check' : 'uncheck' );
});
});
// Inline save — SKU, ilość, cena
var fieldUrlMap = {
'sku': '/admin/shop_product/product_combination_sku_save/',
'quantity': '/admin/shop_product/product_combination_quantity_save/',
'price': '/admin/shop_product/product_combination_price_save/'
};
$( 'body' ).on( 'change', '.combination-field', function()
{
var $input = $( this );
var field = $input.data( 'field' );
var data = { product_id: $input.data( 'product-id' ) };
data[ field ] = $input.val();
$.ajax({
type: 'POST',
cache: false,
url: fieldUrlMap[ field ],
data: data,
beforeSend: function() {
$( '#overlay' ).show();
},
success: function( data ) {
$( '#overlay' ).hide();
var response = jQuery.parseJSON( data );
if ( response.status === 'ok' ) {
$input.css( 'border-color', '#1cbb8c' );
setTimeout( function() { $input.css( 'border-color', '' ); }, 1500 );
} else {
$input.css( 'border-color', '#ff3d60' );
setTimeout( function() { $input.css( 'border-color', '' ); }, 1500 );
if ( response.msg ) create_error( response.msg );
}
},
error: function() {
$( '#overlay' ).hide();
$input.css( 'border-color', '#ff3d60' );
setTimeout( function() { $input.css( 'border-color', '' ); }, 1500 );
}
});
});
// Inline save — checkbox stock_0_buy (iCheck event)
$( 'body' ).on( 'ifChanged', '.combination-checkbox', function()
{
var $cb = $( this );
$.ajax({
type: 'POST',
cache: false,
url: '/admin/shop_product/product_combination_stock_0_buy_save/',
data: { product_id: $cb.data( 'product-id' ), stock_0_buy: $cb.is( ':checked' ) },
beforeSend: function() {
$( '#overlay' ).show();
},
success: function( data ) {
$( '#overlay' ).hide();
var response = jQuery.parseJSON( data );
if ( response.status !== 'ok' && response.msg ) {
create_error( response.msg );
}
},
error: function() {
$( '#overlay' ).hide();
}
});
});
// Usuwanie kombinacji — AJAX
$( 'body' ).on( 'click', '.btn-delete-permutation', function(e)
{
e.preventDefault();
var href = $( this ).attr( 'href' );
var combinationId = $( this ).data( 'combination-id' );
var $row = $( this ).closest( 'tr' );
$.alert(
{
@@ -128,96 +196,34 @@
text: 'Tak',
btnClass: 'btn-danger',
keys: ['enter'],
action: function() {
document.location.href = href;
action: function()
{
$.ajax({
type: 'POST',
cache: false,
url: '/admin/shop_product/delete_combination_ajax/',
data: { combination_id: combinationId },
beforeSend: function() {
$( '#overlay' ).show();
},
success: function( data ) {
$( '#overlay' ).hide();
var response = jQuery.parseJSON( data );
if ( response.status === 'ok' ) {
$row.fadeOut( 300, function() { $( this ).remove(); } );
} else {
if ( response.msg ) create_error( response.msg );
}
},
error: function() {
$( '#overlay' ).hide();
}
});
}
}
}
});
return false;
});
$( 'body' ).on( 'click', '.baselinker-product-search', function() {
var product_id = $( this ).attr( 'product-id' );
$.ajax({
type: 'POST',
cache: false,
url: '/admin/shop_product/baselinker_product_search/',
data: {
product_id: product_id
},
beforeSend: function() {
$( '#overlay' ).show();
},
success: function( response ) {
data = jQuery.parseJSON( response );
if ( data.status == 'SUCCESS' ) {
$('.baselinker-found-products').remove();
var html = '<div class="baselinker-found-products">';
html += '<p>Znaleziono ' + data.products.length + ' produktów</p>';
html += '<select class="form-control baselinker-product-select" product-id="' + product_id + '">';
$.each( data.products, function( index, value ) {
html += '<option value="' + value.product_id + '">' + value.name + ' SKU: ' + value.sku + '</option>';
});
html += '</select>';
html += '<button class="btn btn-success baselinker-product-select-save" product-id="' + product_id + '">Zapisz</button>';
html += '</div>';
$( 'span[product-id="' + product_id + '"]' ).closest( 'td' ).append( html );
} else if ( data.status == 'error' ) {
$.alert({
title: 'Błąd',
content: data.msg,
type: 'red',
closeIcon: true,
closeIconClass: 'fa fa-times',
typeAnimated: true,
animation: 'opacity',
columnClass: 'col-12 col-lg-10',
theme: 'modern',
icon: 'fa fa-exclamation-triangle',
buttons: {
confirm: {
text: 'OK',
btnClass: 'btn-danger',
keys: ['enter'],
action: function() {}
}
}
});
}
}
});
});
$( 'body' ).on( 'click', '.baselinker-product-select-save', function(){
var product_id = $( this ).attr( 'product-id' );
var baselinker_product_id = $( '.baselinker-product-select[product-id="' + product_id + '"]' ).val();
var baselinker_product_name = $( '.baselinker-product-select[product-id="' + product_id + '"] option:selected' ).text();
$.ajax({
type: 'POST',
cache: false,
url: '/admin/shop_product/baselinker_product_select_save/',
data: {
product_id: product_id,
baselinker_product_id: baselinker_product_id,
baselinker_product_name: baselinker_product_name
},
beforeSend: function() {
$( '#overlay' ).show();
},
success: function( response ) {
data = jQuery.parseJSON( response );
if ( data.status == 'ok' ) {
$( '.baselinker-product-select[product-id="' + product_id + '"]' ).closest( '.baselinker-found-products' ).remove();
$( 'span[product-id="' + product_id + '"]' ).html( '<span title="' + baselinker_product_name + '">' + baselinker_product_name.substr( 0, 25 ) + '...</span>' ).removeClass( 'baselinker-product-search' ).removeClass( 'text-danger' );
}
}
});
});
});
</script>
</script>