Integrations DI refactor, remove Sellasist/Baselinker, fix product-edit encoding (0.263)

- New: Domain\Integrations\IntegrationsRepository + admin\Controllers\IntegrationsController (DI)
- Cleanup: removed all Sellasist and Baselinker integrations from entire project
- Fix: product-edit.php Polish characters (UTF-8/CP1250 double-encoding)
- Update: factory\Integrations as facade (Apilo + ShopPRO only)
- Tests: 212 tests, 577 assertions

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-13 21:59:26 +01:00
parent 67705f1f56
commit d824ba3909
51 changed files with 1166 additions and 2663 deletions

View File

@@ -19,7 +19,6 @@
<th>Stan magazynowy</th>
<th>Cena netto</th>
<th>Zam. SM 0</th>
<th>Baselinker</th>
<th style="width: 100px;">Opcje</th>
</tr>
</thead>
@@ -50,14 +49,6 @@
<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>";
?>
</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>
</td>
@@ -138,86 +129,5 @@
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>

View File

@@ -21,15 +21,15 @@ ob_start();
<div id="settings-tabs">
<ul class="resp-tabs-list settings-tabs">
<li><i class="fa fa-file"></i>Opis</li>
<li><i class="fa fa-file"></i>Zakładki</li>
<li><i class="fa fa-file"></i>Zakładki</li>
<li><i class="fa fa-dollar"></i>Cena</li>
<li><i class="fa fa-home"></i>Magazyn</li>
<li><i class="fa fa-wrench"></i>Ustawienia</li>
<li><i class="fa fa-globe"></i>SEO</li>
<li><i class="fa fa-share-alt"></i>Wyświetlanie</li>
<li><i class="fa fa-share-alt"></i>Wyświetlanie</li>
<li><i class="fa fa-file-image-o"></i>Galeria</li>
<li><i class="fa fa-file-archive-o"></i>Załączniki</li>
<li><i class="fa fa-exchange"></i>Produkty powiÄ…zane</li>
<li><i class="fa fa-file-archive-o"></i>Załączniki</li>
<li><i class="fa fa-exchange"></i>Produkty powiązane</li>
<li><i class="fa fa-file-excel-o"></i>XML</li>
<li><i class="fa fa-file-o"></i>Dodatkowe pola</li>
<li><i class="fa fa-file-o"></i>GPSR</li>
@@ -40,7 +40,7 @@ ob_start();
<ul class="resp-tabs-list languages-main htabs">
<? if (is_array($this->languages)) : foreach ($this->languages as $lg) : ?>
<? if ($lg['status']) : ?>
<li><? if ($lg['id'] == \front\factory\Languages::default_language()) echo '<i class="fa fa-star fa-lg text-system" title="Język domyślny"></i> '; ?><?= $lg['name']; ?></a></li>
<li><? if ($lg['id'] == \front\factory\Languages::default_language()) echo '<i class="fa fa-star fa-lg text-system" title="Język domyślny"></i> '; ?><?= $lg['name']; ?></a></li>
<? endif; ?>
<?
endforeach;
@@ -52,7 +52,7 @@ ob_start();
<?
$languages = array();
$languages[''] = '---- wersja językowa ----';
$languages[''] = '---- wersja językowa ----';
if (is_array($this->languages))
foreach ($this->languages as $lg_tmp)
{
@@ -65,7 +65,7 @@ ob_start();
<?=
\Html::select(
array(
'label' => 'Wyświetlaj treść z wersji',
'label' => 'Wyświetlaj treść z wersji',
'name' => 'copy_from[' . $lg['id'] . ']',
'values' => $languages,
'value' => $this->product['languages'][$lg['id']]['copy_from'],
@@ -86,7 +86,7 @@ ob_start();
<?=
\Html::input(
array(
'label' => 'Komunikat gdy stan magazynowy rĂłwny 0',
'label' => 'Komunikat gdy stan magazynowy równy 0',
'name' => 'warehouse_message_zero[' . $lg['id'] . ']',
'id' => 'warehouse_message_zero_' . $lg['id'],
'value' => $this->product['languages'][$lg['id']]['warehouse_message_zero'],
@@ -97,7 +97,7 @@ ob_start();
<?=
\Html::input(
array(
'label' => 'Komunikat gdy stan magazynowy większy niż 0',
'label' => 'Komunikat gdy stan magazynowy większy niż 0',
'name' => 'warehouse_message_nonzero[' . $lg['id'] . ']',
'id' => 'warehouse_message_nonzero_' . $lg['id'],
'value' => $this->product['languages'][$lg['id']]['warehouse_message_nonzero'],
@@ -108,7 +108,7 @@ ob_start();
<?=
\Html::textarea(
array(
'label' => 'KrĂłtki opis',
'label' => 'Krótki opis',
'name' => 'short_description[' . $lg['id'] . ']',
'id' => 'short_description_' . $lg['id'],
'value' => $this->product['languages'][$lg['id']]['short_description'],
@@ -154,7 +154,7 @@ ob_start();
<ul class="resp-tabs-list languages-tabs htabs">
<? if (is_array($this->languages)) : foreach ($this->languages as $lg) : ?>
<? if ($lg['status']) : ?>
<li><? if ($lg['id'] == \front\factory\Languages::default_language()) echo '<i class="fa fa-star fa-lg text-system" title="Język domyślny"></i> '; ?><?= $lg['name']; ?></a></li>
<li><? if ($lg['id'] == \front\factory\Languages::default_language()) echo '<i class="fa fa-star fa-lg text-system" title="Język domyślny"></i> '; ?><?= $lg['name']; ?></a></li>
<? endif; ?>
<?
endforeach;
@@ -166,7 +166,7 @@ ob_start();
<?
$languages = array();
$languages[''] = '---- wersja językowa ----';
$languages[''] = '---- wersja językowa ----';
if (is_array($this->languages))
foreach ($this->languages as $lg_tmp)
{
@@ -179,7 +179,7 @@ ob_start();
<?=
\Html::input(
array(
'label' => 'Nazwa zakładki (1)',
'label' => 'Nazwa zakładki (1)',
'name' => 'tab_name_1[' . $lg['id'] . ']',
'id' => 'tab_name_1_' . $lg['id'],
'value' => $this->product['languages'][$lg['id']]['tab_name_1'],
@@ -190,7 +190,7 @@ ob_start();
<?=
\Html::textarea(
array(
'label' => 'Zawartość zakładki (1)',
'label' => 'Zawartość zakładki (1)',
'name' => 'tab_description_1[' . $lg['id'] . ']',
'id' => 'tab_description_1_' . $lg['id'],
'value' => $this->product['languages'][$lg['id']]['tab_description_1'],
@@ -201,7 +201,7 @@ ob_start();
<?=
\Html::input(
array(
'label' => 'Nazwa zakładki (2)',
'label' => 'Nazwa zakładki (2)',
'name' => 'tab_name_2[' . $lg['id'] . ']',
'id' => 'tab_name_2_' . $lg['id'],
'value' => $this->product['languages'][$lg['id']]['tab_name_2'],
@@ -212,7 +212,7 @@ ob_start();
<?=
\Html::textarea(
array(
'label' => 'Zawartość zakładki (2)',
'label' => 'Zawartość zakładki (2)',
'name' => 'tab_description_2[' . $lg['id'] . ']',
'id' => 'tab_description_2_' . $lg['id'],
'value' => $this->product['languages'][$lg['id']]['tab_description_2'],
@@ -305,7 +305,7 @@ ob_start();
?>
<?
$units[] = '--- wybierze jednostkÄ™ miary ---';
$units[] = '--- wybierze jednostkę miary ---';
foreach ($this->units as $unit)
$units[$unit['id']] = $unit['text'];
?>
@@ -317,7 +317,7 @@ ob_start();
'value' => $this->product['product_unit_id']
]); ?>
<?= \Html::input([
'label' => 'Waga/pojemność',
'label' => 'Waga/pojemność',
'name' => 'weight',
'id' => 'weight',
'class' => 'number-format',
@@ -336,14 +336,14 @@ ob_start();
?>
<?=
\Html::input_switch([
'label' => 'Pozwól zamawiać gdy stan 0',
'label' => 'Pozwól zamawiać gdy stan 0',
'name' => 'stock_0_buy',
'checked' => $this->product['stock_0_buy'] == 1 ? true : false
]);
?>
<?=
\Html::input([
'label' => 'Współczynnik WP',
'label' => 'Współczynnik WP',
'name' => 'wp',
'id' => 'wp',
'class' => 'number-format',
@@ -382,7 +382,7 @@ ob_start();
?>
<?=
\Html::input([
'label' => 'Nowość do dnia',
'label' => 'Nowość do dnia',
'name' => 'new_to_date',
'id' => 'new_to_date',
'class' => 'date',
@@ -390,19 +390,19 @@ ob_start();
]);
?>
<?= \Html::input_switch([
'label' => 'Wyświetlaj pole na dodatkową wiadomość',
'label' => 'Wyświetlaj pole na dodatkową wiadomość',
'name' => 'additional_message',
'checked' => $this->product['additional_message'] == 1 ? true : false
]);
?>
<?= \Html::input_switch([
'label' => 'Dodatkowa wiadomość jest wymagana',
'label' => 'Dodatkowa wiadomość jest wymagana',
'name' => 'additional_message_required',
'checked' => $this->product['additional_message_required'] == 1 ? true : false
]);
?>
<?= \Html::input([
'label' => 'Dodatkowa wiadomość (treść komunikatu)',
'label' => 'Dodatkowa wiadomość (treść komunikatu)',
'name' => 'additional_message_text',
'id' => 'additional_message_text',
'value' => $this->product['additional_message_text']
@@ -414,7 +414,7 @@ ob_start();
<ul class="resp-tabs-list languages-seo htabs">
<? if (is_array($this->languages)) : foreach ($this->languages as $lg) : ?>
<? if ($lg['status']) : ?>
<li><? if ($lg['id'] == \front\factory\Languages::default_language()) echo '<i class="fa fa-star fa-lg text-system" title="Język domyślny"></i> '; ?><?= $lg['name']; ?></li>
<li><? if ($lg['id'] == \front\factory\Languages::default_language()) echo '<i class="fa fa-star fa-lg text-system" title="Język domyślny"></i> '; ?><?= $lg['name']; ?></li>
<? endif; ?>
<?
endforeach;
@@ -481,7 +481,7 @@ ob_start();
</div>
<div>
<?
$layouts[''] = '---- szablon domyślny ----';
$layouts[''] = '---- szablon domyślny ----';
if (is_array($this->layouts)) : foreach ($this->layouts as $layout) :
$layouts[$layout['id']] = $layout['name'];
endforeach;
@@ -497,7 +497,7 @@ ob_start();
]);
?>
<div class="form-group row">
<label class="col-md-4 control-label">Wyświetlaj w:</label>
<label class="col-md-4 control-label">Wyświetlaj w:</label>
<div class="col-md-8">
<div class="menu_sortable">
<ol class="sortable" id="sortable">
@@ -580,7 +580,7 @@ ob_start();
</div>
<div>
<div class="form-group row">
<label class="col-lg-4 control-label">Wybierz zdefiniowany komplet produktĂłw:</label>
<label class="col-lg-4 control-label">Wybierz zdefiniowany komplet produktów:</label>
<div class="col-lg-8">
<select id="set" class="form-control" name="set">
<option value="">wybierz komplet...</option>
@@ -591,9 +591,9 @@ ob_start();
</div>
</div>
<div class="form-group row">
<label class="col-lg-4 control-label">Produkty powiÄ…zane:</label>
<label class="col-lg-4 control-label">Produkty powiązane:</label>
<div class="col-lg-8">
<select id="products_related" multiple name="products_related[]" placeholder="produkty powiÄ…zane">
<select id="products_related" multiple name="products_related[]" placeholder="produkty powiązane">
<option value="">wybierz produkt...</option>
<? foreach ($this->products as $key => $val) : ?>
<? if ($key != $this->product['id']) : ?>
@@ -622,7 +622,7 @@ ob_start();
<? if (is_array($this->languages)) : foreach ($this->languages as $lg) : ?>
<? if ($lg['status']) : ?>
<div id="xml_name_<?= $this->i; ?>_<?= $lg['id']; ?>" class="tab-pane <? if (!$z++) : ?>active<? endif; ?>">
<label class="col-lg-4 control-label">Nazwa produktu XML (150 znakĂłw):</label>
<label class="col-lg-4 control-label">Nazwa produktu XML (150 znaków):</label>
<div class="col-lg-8">
<input type="text" class="form-control" name="xml_name[<?= $lg['id']; ?>]" value="<?= $this->product['languages'][$lg['id']]['xml_name']; ?>">
</div>
@@ -700,7 +700,7 @@ ob_start();
</div>
<div class="form-group row">
<div class="col-sm-12 text-right">
<span class="input-group-addon btn btn-info" onclick="remove_custom_filed( $( this ) );">usuń</span>
<span class="input-group-addon btn btn-info" onclick="remove_custom_filed( $( this ) );">usuń</span>
</div>
</div>
</div>
@@ -724,7 +724,7 @@ ob_start();
<ul class="resp-tabs-list gpsr-seo htabs">
<? if ( is_array( $this -> languages ) ): foreach ( $this -> languages as $lg ):?>
<? if ($lg['status']) : ?>
<li><? if ($lg['id'] == \front\factory\Languages::default_language()) echo '<i class="fa fa-star fa-lg text-system" title="Język domyślny"></i> '; ?><?= $lg['name']; ?></li>
<li><? if ($lg['id'] == \front\factory\Languages::default_language()) echo '<i class="fa fa-star fa-lg text-system" title="Język domyślny"></i> '; ?><?= $lg['name']; ?></li>
<? endif; ?>
<? endforeach; endif; ?>
</ul>
@@ -733,7 +733,7 @@ ob_start();
<? if ( $lg['status'] ):?>
<div>
<?= \Html::textarea( [
'label' => 'Informacje o bezpieczeństwie ('.$lg['name'].')',
'label' => 'Informacje o bezpieczeństwie ('.$lg['name'].')',
'name' => 'security_information[' . $lg['id'] . ']',
'id' => 'security_information_' . $lg['id'],
'value' => $this->product['languages'][$lg['id']]['security_information']
@@ -776,7 +776,7 @@ $grid->actions = [
];
$grid->buttons = [
[
'label' => 'PodglÄ…d',
'label' => 'Podgląd',
'id' => 'product-preview',
'url' => '#',
'icon' => 'fa-search',
@@ -845,7 +845,7 @@ echo $grid->draw();
html += '</div>';
html += '<div class="form-group row">';
html += '<div class="col-sm-12 text-right">';
html += '<span class="input-group-addon btn btn-info" onclick="remove_custom_filed( $( this ) );">usuń</span>';
html += '<span class="input-group-addon btn btn-info" onclick="remove_custom_filed( $( this ) );">usuń</span>';
html += '</div>';
html += '</div>';
html += '</div>';
@@ -1138,8 +1138,8 @@ echo $grid->draw();
$(this).blur();
var file_id = $(this).attr('file_id');
$.prompt('Na pewno chcesz usunąć wybrany plik?', {
title: 'PotwierdĹş?',
$.prompt('Na pewno chcesz usunąć wybrany plik?', {
title: 'Potwierdź?',
submit: function(e, v, m, f) {
if (v === true) {
$.ajax({
@@ -1178,8 +1178,8 @@ echo $grid->draw();
$(this).blur();
var image_id = $(this).attr('image-id');
$.prompt('Na pewno chcesz usunąć wybrane zdjęcie?', {
title: 'PotwierdĹş?',
$.prompt('Na pewno chcesz usunąć wybrane zdjęcie?', {
title: 'Potwierdź?',
submit: function(e, v, m, f) {
if (v === true) {
$.ajax({

View File

@@ -36,23 +36,6 @@
<td class="text-center">
<span class="text-muted"><?= (int)\admin\factory\shopProduct::get_product_quantity_list( $product['id'] );?></span>
</td>
<? if ( $this -> baselinker_enabled ):?>
<td class="text-center">
<?
if ( $product['baselinker_product_name'] != "" ) {
echo "<span title='" . htmlspecialchars( $product['baselinker_product_name'] ) . "'>" . mb_substr( $product['baselinker_product_name'], 0, 25, 'UTF-8' ) . "...</span>";
echo "<br>";
echo "<span class='text-danger baselinker-delete-linking' product-id='" . $product['id'] . "'>";
echo "<i class='fa fa-times'></i>usuń powiązanie";
echo "</span>";
} else {
echo "<span class='text-danger baselinker-product-search' product-id='" . $product['id'] . "'>";
echo "nie przypisano <i class='fa fa-search'></i>";
echo "</span>";
}
?>
</td>
<? endif;?>
<? if ( $this -> apilo_enabled ):?>
<td class="text-center">
<?
@@ -70,24 +53,6 @@
?>
</td>
<? endif;?>
<!-- sellasist -->
<? if ( $this -> sellasist_enabled ):?>
<td class="text-center">
<?
if ( $product['sellasist_product_name'] != "" ) {
echo "<span title='" . htmlspecialchars( $product['sellasist_product_name'] ) . "'>" . mb_substr( $product['sellasist_product_name'], 0, 25, "UTF-8" ) . "...</span>";
echo "<br>";
echo "<span class='text-danger sellasist-delete-linking' product-id='" . $product['id'] . "'>";
echo "<i class='fa fa-times'></i>usuń powiązanie";
echo "</span>";
} else {
echo "<span class='text-danger sellasist-product-search' product-id='" . $product['id'] . "'>";
echo "nie przypisano <i class='fa fa-search'></i>";
echo "</span>";
}
?>
</td>
<? endif;?>
<td>
<a href='/admin/shop_product/product_combination/product_id=<?= $product['id'];?>'>kombinacje (<?= \admin\factory\shopProduct::count_product_combinations( $product['id'] );?>)</a>
</td>

View File

@@ -23,15 +23,9 @@
<th class="text-center" style="width: 25px;">Promowany</th>
<th class="text-center" style="width: 25px;">Aktywny</th>
<th class="text-center" style="width: 75px;">Stan MG</th>
<? if ( $this -> baselinker_enabled ):?>
<th class="text-center" style="width: 100px;">Baselinker</th>
<? endif;?>
<? if ( $this -> apilo_enabled ):?>
<th class="text-center" style="width: 100px;">Apilo</th>
<? endif;?>
<? if ( $this -> sellasist_enabled ):?>
<th class="text-center" style="width: 100px;">Sellasist</th>
<? endif;?>
<th class="text-center" style="width: 100px;">Kombinacje</th>
<th class="text-center" style="width: 75px;">Edytuj</th>
<th class="text-center" style="width: 75px;">Archiwizuj</th>
@@ -305,60 +299,6 @@
});
})
// sellasist product search
$( 'body' ).on( 'click', '.sellasist-product-search', function() {
var product_id = $( this ).attr( 'product-id' );
$.ajax({
type: 'POST',
cache: false,
url: '/admin/integrations/sellasist_product_search/',
data: {
product_id: product_id
},
beforeSend: function() {
$( '#overlay' ).show();
},
success: function( response ) {
data = jQuery.parseJSON( response );
if ( data.status == 'SUCCESS' ) {
var html = '<div class="sellasist-found-products">';
html += '<p>Znaleziono ' + data.products.length + ' produktów</p>';
html += '<select class="form-control sellasist-product-select" product-id="' + product_id + '">';
$.each( data.products, function( index, value ) {
html += '<option value="' + value.id + '">' + value.name + ' SKU: ' + value.symbol + '</option>';
});
html += '</select>';
html += '<button class="btn btn-success sellasist-product-select-save" product-id="' + product_id + '">Zapisz</button>';
html += '</div>';
$( 'span.sellasist-product-search[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() {}
}
}
});
}
}
});
});
// apilo product search
$( 'body' ).on( 'click', '.apilo-product-search', function() {
var product_id = $( this ).attr( 'product-id' );
@@ -380,9 +320,8 @@
{
if ( data.products.length == 0 )
{
var html = '<div class="baselinker-found-products">';
var html = '<div class="apilo-found-products">';
html += '<p>Nie znaleziono produktów</p>';
// button to create product on baselinker
html += '<a href="/admin/integrations/apilo_create_product/product-id=' + product_id + '" class="btn btn-success btn_apilo_create_product" product_id="' + product_id + '">Utwórz produkt</a>';
html += '</div>';
$( 'span.apilo-product-search[product-id="' + product_id + '"]' ).closest( 'td' ).append( html );
@@ -428,30 +367,6 @@
});
});
// sellasist product delete linking
$( 'body' ).on( 'click', '.sellasist-delete-linking', function() {
var product_id = $( this ).attr( 'product-id' );
$.ajax({
type: 'POST',
cache: false,
url: '/admin/integrations/sellasist_product_select_delete/',
data: {
product_id: product_id
},
beforeSend: function() {
$( '#overlay' ).show();
},
success: function( response ) {
data = jQuery.parseJSON( response );
if ( data.status == 'ok' ) {
$( 'span.sellasist-delete-linking[product-id="' + product_id + '"]' ).closest('td').html( '<span class="text-danger sellasist-product-search" product-id="' + product_id + '">nie przypisano <i class="fa fa-search"></i></span>' );
}
}
});
});
// delete apilo product linking
$( 'body' ).on( 'click', '.apilo-delete-linking', function() {
var product_id = $( this ).attr( 'product-id' );
@@ -476,31 +391,7 @@
});
});
// delete baselinker product linking
$( 'body' ).on( 'click', '.baselinker-delete-linking', function() {
var product_id = $( this ).attr( 'product-id' );
$.ajax({
type: 'POST',
cache: false,
url: '/admin/integrations/baselinker_product_select_delete/',
data: {
product_id: product_id
},
beforeSend: function() {
$( '#overlay' ).show();
},
success: function( response ) {
data = jQuery.parseJSON( response );
if ( data.status == 'ok' ) {
$( 'span.baselinker-delete-linking[product-id="' + product_id + '"]' ).closest('td').html( '<span class="text-danger baselinker-product-search" product-id="' + product_id + '">nie przypisano <i class="fa fa-search"></i></span>' );
}
}
});
});
// aplio product create button click with alert confirmation
// apilo product create button click with alert confirmation
$( 'body' ).on( 'click', '.btn_apilo_create_product', function(e)
{
e.preventDefault();
@@ -540,137 +431,6 @@
});
});
// baselinker product create button click with alert confirmation
$( 'body' ).on( 'click', '.btn-create-product', function(e) {
e.preventDefault();
var product_id = $( this ).attr( 'product-id' );
$.alert({
title: 'Pytanie',
content: 'Na pewno chcesz utworzyć produkt w bazie Baselinker?',
type: 'orange',
closeIcon: true,
closeIconClass: 'fa fa-times',
typeAnimated: true,
animation: 'opacity',
columnClass: 'col-12 col-lg-10',
theme: 'modern',
icon: 'fa fa-question',
buttons: {
confirm: {
text: 'Tak',
btnClass: 'btn-success',
keys: ['enter'],
action: function() {
document.location.href = '/admin/integrations/baselinker_create_product/product_id=' + product_id;
}
},
cancel: {
text: 'Nie',
btnClass: 'btn-danger',
action: function() {}
}
}
});
});
$( 'body' ).on( 'click', '.baselinker-product-search', function() {
var product_id = $( this ).attr( 'product-id' );
$.ajax({
type: 'POST',
cache: false,
url: '/admin/integrations/baselinker_product_search/',
data: {
product_id: product_id
},
beforeSend: function() {
$( '#overlay' ).show();
},
success: function( response ) {
data = jQuery.parseJSON( response );
if ( data.status == 'SUCCESS' )
{
if ( data.products.length == 0 )
{
var html = '<div class="baselinker-found-products">';
html += '<p>Nie znaleziono produktów</p>';
// button to create product on baselinker
html += '<a href="/admin/integrations/baselinker_create_product/product-id=' + product_id + '" class="btn btn-success btn-create-product" product-id="' + product_id + '">Utwórz produkt</a>';
html += '</div>';
$( 'span.baselinker-product-search[product-id="' + product_id + '"]' ).closest( 'td' ).append( html );
}
else
{
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.baselinker-product-search[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() {}
}
}
});
}
}
});
});
// sellasist product select save
$( 'body' ).on( 'click', '.sellasist-product-select-save', function(){
var product_id = $( this ).attr( 'product-id' );
var sellasist_product_id = $( '.sellasist-product-select[product-id="' + product_id + '"]' ).val();
var sellasist_product_name = $( '.sellasist-product-select[product-id="' + product_id + '"] option:selected' ).text();
$.ajax({
type: 'POST',
cache: false,
url: '/admin/integrations/sellasist_product_select_save/',
data: {
product_id: product_id,
sellasist_product_id: sellasist_product_id,
sellasist_product_name: sellasist_product_name
},
beforeSend: function() {
$( '#overlay' ).show();
},
success: function( response ) {
data = jQuery.parseJSON( response );
if ( data.status == 'ok' ) {
$( '.sellasist-product-select[product-id="' + product_id + '"]' ).closest( '.sellasist-found-products' ).remove();
$( 'span.sellasist-product-search[product-id="' + product_id + '"]' ).html( '<span title="' + sellasist_product_name + '">' + sellasist_product_name.substr( 0, 25 ) + '...</span>' ).removeClass( 'sellasist-product-search' ).removeClass( 'text-danger' );
}
}
});
});
// apilo product select save
$( 'body' ).on( 'click', '.apilo-product-select-save', function(){
var product_id = $( this ).attr( 'product-id' );
@@ -700,34 +460,6 @@
});
});
$( '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/integrations/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.baselinker-product-search[product-id="' + product_id + '"]' ).html( '<span title="' + baselinker_product_name + '">' + baselinker_product_name.substr( 0, 25 ) + '...</span>' ).removeClass( 'baselinker-product-search' ).removeClass( 'text-danger' );
}
}
});
});
$( 'body' ).on( 'change', '.product_xml_name', function() {
var product_id = $( this ).attr( 'product-id' );
var product_xml_name = $( this ).val();