first commit

This commit is contained in:
2024-11-05 12:22:50 +01:00
commit e5682a3912
19641 changed files with 2948548 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
<?php
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../');
exit;

View File

@@ -0,0 +1,232 @@
var x13Import = (function ($, module) {
$(function() {
$(document).on('keyup x-cast', '.x-cast', function() {
$(this).val(module.castNumber($(this).val()));
});
$(document).on('focusout x-cast', '.x-cast', function() {
var value = $(this).val();
if (!value.length) {
value = 0;
}
if ($(this).hasClass('x-cast-float')) {
value = module.castFloat(value);
} else {
value = module.castInt(value);
}
if ($(this).hasClass('x-cast-blank') && (value === 0 || value === '0.00')) {
value = '';
}
$(this).val(value);
});
$('.x-cast').trigger('x-cast');
});
module.getWholesalers = function (callback) {
var ajaxData = {
action: 'getWholesalers'
};
x13Import.ajax(
ajaxData,
null,
function(json) {
json.wholesalers.forEach(function(value) {
x13Import.progressBlock.wholesaler(value);
});
callback(json.wholesalers);
},
function() {
callback([]);
}
);
}
module.disableButton = function(button) {
button.addClass('disabled').attr('disabled', 'disabled');
button.find('i').attr('data-class', button.find('i').attr('class')).attr('class', 'process-icon-loading');
}
module.enableButton = function(button) {
button.removeClass('disabled').removeAttr('disabled');
button.find('i').attr('class', button.find('i').attr('data-class')).removeAttr('data-class');
}
module.castNumber = function(value) {
return value.replace(/[^0-9,.\-]/g, '').replace(',', '.');
}
module.castInt = function(value) {
return parseInt(value);
}
module.castFloat = function(value) {
value = parseFloat(value).toFixed(10);
var pow = Math.pow(10, 2);
value *= pow;
var nextDigit = Math.floor(value * 10) - 10 * Math.floor(value);
value = (nextDigit >= 5 ? Math.ceil(value) : Math.floor(value));
return (value / pow).toFixed(2);
}
module.redirect = function(controller, params) {
var ajaxData = {
action: 'getRedirectLink',
linkController: controller,
linkParams: params
};
this.ajax(
ajaxData,
null,
function(json) {
if (json.redirectLink) {
setTimeout(function() {
location.replace(json.redirectLink);
}, 1000);
}
}
);
}
module.ajax = function(data, beforeSend, success, error) {
var defaultData = {
token: x13importToken,
ajax: true
};
$.ajax({
url: currentIndex,
method: 'POST',
async: true,
dataType: 'json',
data: $.extend(defaultData, data),
beforeSend: beforeSend,
success: function(json) {
if (success) {
success(json);
}
},
error: error
});
}
return module;
}(jQuery, x13Import || {}));
x13Import.progressBlock = (function ($) {
var progressBlockElement,
progressBlockPattern;
$(function() {
progressBlockElement = $('#ximport_progress_block');
progressBlockPattern = $('#_pattern_ximport_progress_block');
progressBlockElement.find('.x-close a').on('click', function (e) {
e.preventDefault();
progressBlockElement.slideUp('slow');
});
});
var progressBlock = {};
progressBlock.wholesalerActionProcess = 'badge';
progressBlock.wholesalerActionSuccess = 'badge badge-success';
progressBlock.wholesalerActionError = 'badge badge-danger';
progressBlock.init = function (header, description)
{
progressBlockElement.find('.x-header').text(header);
progressBlockElement.find('.x-description').text((description ? description : ''));
progressBlockElement.find('.x-bar').hide();
progressBlockElement.find('.x-bar-visual > div').css('width', 0);
progressBlockElement.find('.x-form').empty();
progressBlockElement.find('.x-content').html(progressBlockPattern.find('#_pattern_content').html());
progressBlockElement.find('.x-close').hide();
progressBlockElement.slideDown('slow');
}
progressBlock.description = function (description) {
if (description === undefined) {
progressBlockElement.find('.x-description').hide();
} else {
progressBlockElement.find('.x-description').text(description).show();
}
}
progressBlock.bar = function (value) {
if (value === undefined) {
progressBlockElement.find('.x-bar').hide();
} else {
progressBlockElement.find('.x-bar').show();
progressBlockElement.find('.x-bar-visual > div').css('width', value + '%');
}
}
progressBlock.messageBefore = function (message) {
if (message === undefined) {
progressBlockElement.find('.x-message-before').hide();
} else {
progressBlockElement.find('.x-message-before').text(message).show();
}
}
progressBlock.messageAfter = function (message) {
if (message === undefined) {
progressBlockElement.find('.x-message-after').hide();
} else {
progressBlockElement.find('.x-message-after').text(message).show();
}
}
progressBlock.form = function (html) {
if (html === undefined) {
progressBlockElement.find('.x-form').hide();
} else {
progressBlockElement.find('.x-form').html(html).show();
}
}
progressBlock.refreshButton = function (message) {
if (message === undefined) {
progressBlockElement.find('.x-refresh-button').hide();
} else {
progressBlockElement.find('.x-refresh-button').show().find('a').append('&nbsp;&nbsp;' + message);
}
}
progressBlock.wholesaler = function (wholesalerName) {
var block = progressBlockPattern.find('#_pattern_list_wholesalers > li').clone();
$('.x-list-wholesaler', block).text(wholesalerName);
block.attr('id', 'wholesaler' + wholesalerName);
block.appendTo(progressBlockElement.find('.x-list'));
}
progressBlock.wholesalerAction = function (wholesalerName, action, message) {
var wholesalerElement = progressBlockElement.find('.x-list #wholesaler' + wholesalerName).find('.x-list-wholesaler-action');
wholesalerElement.addClass(action);
if (message !== undefined) {
wholesalerElement.text(message);
}
}
progressBlock.close = function () {
progressBlockElement.find('.x-close').show();
}
return progressBlock;
}(jQuery));

View File

@@ -0,0 +1,281 @@
(function ($, x13Import) {
var IMPORT_LIMIT = 10;
$(function () {
var buttonCategoriesDownload = $('.x-categories-download').parent();
var buttonCategoriesImport = $('.x-categories-import').parent();
$(buttonCategoriesDownload).on('click', function(e) {
if ($(this).attr('disabled')) {
return false;
}
e.preventDefault();
x13Import.disableButton($(this));
window.scrollTo(0, 0);
x13Import.progressBlock.init('Pobieranie kategorii z hurtowni');
var self = $(this);
x13Import.getWholesalers(function(wholesalers) {
var requestStatus = true;
var requestLoop = function(index) {
if (index in wholesalers) {
categoriesDownload(wholesalers[index], function(status) {
requestStatus &= status;
requestLoop(++index);
});
} else {
x13Import.enableButton(self);
if (requestStatus) {
x13Import.redirect(help_class_name, 'categoriesDownloadSuccess');
} else {
x13Import.progressBlock.messageBefore('W jednej z hurtowni wystąpił błąd podczas pobierania kategorii');
x13Import.progressBlock.refreshButton('Przeładuj stronę');
}
}
}
if (wholesalers.length) {
requestLoop(0);
} else {
x13Import.progressBlock.description('Brak hurtowni');
x13Import.enableButton(self);
}
});
});
$(buttonCategoriesImport).on('click', function(e) {
if ($(this).attr('disabled')) {
return false;
}
e.preventDefault();
window.scrollTo(0, 0);
x13Import.progressBlock.init('Import kategorii do sklepu', 'Wybierz metodę importu kategorii');
categoriesImportForm();
var self = $(this);
$(document).on('click', 'button[name="submitCategoriesImportForm"]', function(e) {
e.preventDefault();
var categoriesInput; // PS 1.5 backward compatibility
var categoriesImportMode = parseInt($('input[name="categoriesImportMode"]:checked').val());
var categoriesImportDefault = parseInt($('select[name="categoriesImportDefault"]').val());
var categoriesOverwrite = $('input[name="categoriesOverwrite"]:checked').length;
var categoriesAssigned = [];
var categoriesToAssign = [];
if ($('#categoriesAssigned').length) {
categoriesInput = '#categoriesAssigned input:checked';
} else {
categoriesInput = '#categories-treeview input:checked';
}
$(categoriesInput).each(function() {
categoriesAssigned.push(parseInt($(this).val()));
});
$('input[name="ximport_categoryBox[]"]:checked').each(function() {
categoriesToAssign.push(parseInt($(this).val()));
});
if (categoriesImportMode !== 1) {
if (categoriesAssigned.length === 0) {
alert('Wybierz kategorie sklepu do przypisania');
}
else if (categoriesToAssign.length === 0) {
alert('Wybierz kategorie z hurtowni do importu');
}
else {
var requestLoopSelected = function(index) {
x13Import.progressBlock.bar(Math.min(100, (index * 100) / categoriesToAssign.length));
if (index < categoriesToAssign.length) {
categoriesImportSelected(
categoriesImportMode,
categoriesOverwrite,
categoriesAssigned,
categoriesToAssign.slice(index, index + IMPORT_LIMIT),
categoriesImportDefault,
function() {
requestLoopSelected(index + IMPORT_LIMIT);
}
);
} else {
finishImport();
}
}
prepareProgressBlock();
requestLoopSelected(0);
}
} else {
prepareProgressBlock();
categoriesImportCount(function(count) {
var requestLoop = function(index) {
x13Import.progressBlock.bar(Math.min(100, (index * 100) / count));
if (index < count) {
categoriesImport(IMPORT_LIMIT, function(finish) {
if (!finish) {
requestLoop(index + IMPORT_LIMIT);
} else {
finishImport();
}
});
} else {
finishImport();
}
}
if (count) {
requestLoop(0);
} else {
x13Import.progressBlock.description('Brak kategorii do importu');
x13Import.progressBlock.bar();
x13Import.enableButton(self);
}
});
}
function prepareProgressBlock() {
x13Import.disableButton(self);
$('#categories_import_form').hide();
x13Import.progressBlock.description();
x13Import.progressBlock.bar(0);
}
function finishImport() {
categoriesRegenerateTree(function() {
x13Import.redirect(help_class_name, 'categoriesImportSuccess');
});
}
});
});
});
function categoriesDownload(wholesaler, callback) {
var ajaxData = {
action: 'categoriesDownload',
wholesaler: wholesaler
};
x13Import.ajax(
ajaxData,
function() {
x13Import.progressBlock.wholesalerAction(wholesaler, x13Import.progressBlock.wholesalerActionProcess, 'pobieranie kategorii');
},
function(json) {
if (typeof json.status === "undefined" && json.error) {
// backport to old wholesalers versions with die(['error'])
x13Import.progressBlock.wholesalerAction(wholesaler, x13Import.progressBlock.wholesalerActionError, json.error);
} else if (json.status === true) {
x13Import.progressBlock.wholesalerAction(wholesaler, x13Import.progressBlock.wholesalerActionSuccess, 'zakończono');
} else {
x13Import.progressBlock.wholesalerAction(wholesaler, x13Import.progressBlock.wholesalerActionError, json.message);
}
callback(json.status);
}
);
}
function categoriesImportForm() {
var ajaxData = {
action: 'categoriesImportForm'
};
x13Import.ajax(
ajaxData,
null,
function(json) {
x13Import.progressBlock.form(json.form);
}
);
}
function categoriesImportCount(callback) {
var ajaxData = {
action: 'categoriesImportCount'
};
x13Import.ajax(
ajaxData,
null,
function(json) {
callback(json.count);
},
function() {
callback(0);
}
);
}
function categoriesImport(limit, callback) {
var ajaxData = {
action: 'categoriesImport',
limit: limit
};
x13Import.ajax(
ajaxData,
null,
function(json) {
if (json.status !== true) {
// @todo
}
callback(json.finish);
}
);
}
function categoriesImportSelected(
categoriesImportMode,
categoriesOverwrite,
categoriesAssigned,
categoriesToAssign,
categoriesImportDefault,
callback
) {
var ajaxData = {
action: 'categoriesImportSelected',
categoriesImportMode: categoriesImportMode,
categoriesOverwrite: categoriesOverwrite,
categoriesAssigned: categoriesAssigned,
categoriesToAssign: categoriesToAssign,
categoriesImportDefault: categoriesImportDefault
};
x13Import.ajax(
ajaxData,
null,
function(json) {
if (json.status !== true) {
// @todo
}
callback();
}
);
}
function categoriesRegenerateTree(callback) {
var ajaxData = {
action: 'categoriesRegenerateTree'
};
x13Import.ajax(
ajaxData,
null,
function() {
callback();
}
);
}
}(jQuery, x13Import || {}));

View File

@@ -0,0 +1,220 @@
(function ($, x13Import) {
var DELETE_LIMIT = 25;
$(function () {
$(document).on('change', 'input[name*="AUTO_META_TITLE"]', function () {
if (parseInt($('input[name*="AUTO_META_TITLE"]:checked').val()) === 1) {
$('input[name="wholesaler[' + $(this).attr('data-wholesaler') + '][AUTO_META_TITLE_SCHEMA]"]').closest('.form-group').show();
} else {
$('input[name="wholesaler[' + $(this).attr('data-wholesaler') + '][AUTO_META_TITLE_SCHEMA]"]').closest('.form-group').hide();
}
});
$('input[name*="AUTO_META_TITLE"]').trigger('change');
var buttonProductsDelete = $('.x-products-delete').parent();
var buttonProductsOff = $('.x-products-off').parent();
$(buttonProductsDelete).on('click', function(e) {
if ($(this).attr('disabled')) {
return false;
}
var wholesalerName = $(this).data('wholesaler');
var wholesalerCode = $(this).data('wholesaler-code');
var self = $(this);
if (!confirm('Czy na pewno chcesz usunąć wszystkie produkty' + (wholesalerCode !== undefined ? ' z tej hurtowni' : '') + '?')) {
return false;
}
e.preventDefault();
x13Import.disableButton($(this));
window.scrollTo(0, 0);
x13Import.progressBlock.init('Usuwanie produktów z hurtowni');
if (wholesalerCode !== undefined) {
countProducts(wholesalerCode, function(count) {
var requestLoop = function(index) {
x13Import.progressBlock.bar(Math.min(100, (index * 100) / count));
if (index < count) {
productsDelete(wholesalerName, wholesalerCode, DELETE_LIMIT, function(finish) {
if (!finish) {
requestLoop(index + DELETE_LIMIT);
} else {
x13Import.enableButton(self);
x13Import.progressBlock.wholesalerAction(wholesalerName, x13Import.progressBlock.wholesalerActionSuccess, 'zakończono, usunięte produkty: ' + count);
}
});
} else {
x13Import.enableButton(self);
x13Import.progressBlock.wholesalerAction(wholesalerName, x13Import.progressBlock.wholesalerActionSuccess, 'zakończono, usunięte produkty: ' + count);
}
}
if (count) {
x13Import.progressBlock.wholesaler(wholesalerName);
requestLoop(0);
} else {
x13Import.progressBlock.description('Brak produktów do usunięcia');
x13Import.progressBlock.bar();
x13Import.progressBlock.close();
x13Import.enableButton(self);
}
});
} else {
countProducts('', function(count) {
var requestLoopAll = function(index) {
x13Import.progressBlock.bar(Math.min(100, (index * 100) / count));
if (index < count) {
productsDeleteAll(DELETE_LIMIT, function(finish) {
if (!finish) {
requestLoopAll(index + DELETE_LIMIT);
} else {
x13Import.enableButton(self);
x13Import.progressBlock.close();
x13Import.progressBlock.description('Zakończono, usunięte produkty: ' + count);
}
});
} else {
x13Import.enableButton(self);
x13Import.progressBlock.close();
x13Import.progressBlock.description('Zakończono, usunięte produkty: ' + count);
}
}
if (count) {
requestLoopAll(0);
} else {
x13Import.progressBlock.description('Brak produktów do usunięcia');
x13Import.progressBlock.bar();
x13Import.progressBlock.close();
x13Import.enableButton(self);
}
});
}
});
$(buttonProductsOff).on('click', function(e) {
if ($(this).attr('disabled')) {
return false;
}
var wholesalerName = $(this).data('wholesaler');
var wholesalerCode = $(this).data('wholesaler-code');
var self = $(this);
if (!confirm('Czy na pewno chcesz wyłączyć wszystkie produkty' + (wholesalerCode !== undefined ? ' z tej hurtowni' : '') + '?')) {
return false;
}
e.preventDefault();
x13Import.disableButton($(this));
window.scrollTo(0, 0);
x13Import.progressBlock.init('Wyłączanie produktów z hurtowni');
if (wholesalerCode !== undefined) {
x13Import.progressBlock.wholesaler(wholesalerName);
productsOff(wholesalerName, wholesalerCode, function() {
x13Import.progressBlock.close();
x13Import.enableButton(self);
});
} else {
productsOffAll(function() {
x13Import.progressBlock.close();
x13Import.enableButton(self);
});
}
});
});
function countProducts(wholesalerCode, callback) {
var ajaxData = {
action: 'countProducts',
wholesalerCode: wholesalerCode
};
x13Import.ajax(
ajaxData,
null,
function(json) {
callback(json.count);
},
function() {
callback(0);
}
);
}
function productsDelete(wholesalerName, wholesalerCode, limit, callback) {
var ajaxData = {
action: 'productsDelete',
wholesalerCode: wholesalerCode,
limit: limit
};
x13Import.ajax(
ajaxData,
function() {
x13Import.progressBlock.wholesalerAction(wholesalerName, x13Import.progressBlock.wholesalerActionProcess, 'usuwanie produktów');
},
function(json) {
callback(json.finish);
}
);
}
function productsDeleteAll(limit, callback) {
var ajaxData = {
action: 'productsDelete',
limit: limit
};
x13Import.ajax(
ajaxData,
null,
function(json) {
callback(json.finish);
}
);
}
function productsOff(wholesalerName, wholesalerCode, callback) {
var ajaxData = {
action: 'productsOff',
wholesalerCode: wholesalerCode
};
x13Import.ajax(
ajaxData,
function() {
x13Import.progressBlock.wholesalerAction(wholesalerName, x13Import.progressBlock.wholesalerActionProcess, 'wyłącznie produktów');
},
function(json) {
x13Import.progressBlock.wholesalerAction(wholesalerName, x13Import.progressBlock.wholesalerActionSuccess, 'zakończono, wyłączone produkty: ' + json.count);
callback();
}
);
}
function productsOffAll(callback) {
var ajaxData = {
action: 'productsOff'
};
x13Import.ajax(
ajaxData,
null,
function(json) {
x13Import.progressBlock.description('Zakończono, wyłączone produkty: ' + json.count);
callback();
}
);
}
}(jQuery, x13Import || {}));

View File

@@ -0,0 +1,225 @@
(function($) {
$.XImport = function() {
categoriesList = function() {
var activeMarkup = false;
$(document).on('mouseup', function(e) {
var markupContainer = $('.markup_container');
if (activeMarkup !== false && !activeMarkup.is(e.target) && activeMarkup.has(e.target).length === 0) {
updateMarkup();
}
});
$('span.markup_edit, span.markup_type_edit').on('click', function() {
activeMarkup = $(this).parent();
activeMarkup.find('span.markup_edit').hide().next().attr('x-focus', true).show().css('display', 'inline-block').trigger('focus').trigger('x-cast');
activeMarkup.find('span.markup_type_edit').hide().next().show().css('display', 'inline-block');
});
function updateMarkup()
{
var input = activeMarkup.find('input.markup_edit');
var select = activeMarkup.find('select.markup_type_edit');
input.trigger('x-cast');
input.removeAttr('x-focus').hide().prev().text(input.val()).show();
select.hide().prev().text(select.find('option:selected').text()).show();
activeMarkup = false;
doAdminAjax({
controller: help_class_name,
action: 'updateMarkup',
token: $('input[name=token]').val(),
ajax: true,
id: input.attr('x-id'),
markup: input.val(),
markupType: select.val()
},
function(response) {
var data = $.parseJSON(response);
showSuccessMessage(data.confirmations);
});
}
$('.x-import a').on('click', function() {
var self = $(this);
doAdminAjax(
{
controller: help_class_name,
action: 'updateImport',
token: $('input[name=token]').val(),
id: $(this).parents('tr').find('input[name="ximport_categoryBox[]"]').val(),
ajax: true
},
function(response)
{
var data = $.parseJSON(response);
showSuccessMessage(data.confirmations);
changeStatus(self);
}
);
return false;
});
var bulkMarkup = false;
if ($('.bulkMarkup').length > 0) {
bulkMarkup = $('.bulkMarkup').parent();
}
else if ($('[name="submitBulkmarkupximport_category"]').length > 0) {
bulkMarkup = $('[name="submitBulkmarkupximport_category"]');
}
var bulkTittlePattern = false;
if ($('.bulkTittlePattern').length > 0) {
bulkTittlePattern = $('.bulkTittlePattern').parent();
}
else if ($('[name="submitBulktittlePatternximport_category"]').length > 0) {
bulkTittlePattern = $('[name="submitBulktittlePatternximport_category"]');
}
if (bulkMarkup) {
bulkMarkup.removeAttr('onclick');
bulkMarkup.on('click', function(e) {
e.preventDefault();
if ($('[name="ximport_categoryBox[]"]:checked').length > 0) {
$("#bulk_markup_hidden").empty();
$('[name="ximport_categoryBox[]"]:checked').each(function() {
$("#bulk_markup_hidden").prepend('<input type="hidden" name="ximport_categoryBox[]" value="' + $(this).val() + '">');
});
$.fancybox({
content : $("#ximport_bulk_popup_markup").html(),
autoResize: true,
autoDimensions: true,
helpers: {
overlay: {
locked: false
}
}
});
}
else {
alert('Nie wybrano kategorii.');
}
});
}
if (bulkTittlePattern) {
bulkTittlePattern.removeAttr('onclick');
bulkTittlePattern.on('click', function(e) {
e.preventDefault();
if ($('[name="ximport_categoryBox[]"]:checked').length > 0) {
$("#bulk_title_pattern_hidden").empty();
$('[name="ximport_categoryBox[]"]:checked').each(function() {
$("#bulk_title_pattern_hidden").prepend('<input type="hidden" name="ximport_categoryBox[]" value="' + $(this).val() + '">');
});
$.fancybox({
content : $("#ximport_bulk_popup_title_pattern").html(),
autoResize: true,
autoDimensions: true,
helpers: {
overlay: {
locked: false
}
}
});
}
else {
alert('Nie wybrano kategorii.');
}
});
}
};
excludeList = function() {
$('.x-exclude a').on('click', function() {
var self = $(this);
doAdminAjax(
{
controller: help_class_name,
action: 'excludeProducts',
token: $('input[name=token]').val(),
id: $(this).parents('tr').find('input[name="ximport_productBox[]"]').val(),
ajax: true
},
function(response)
{
var data = $.parseJSON(response);
showSuccessMessage(data.confirmations);
changeStatus(self);
}
);
return false;
});
$('.x-exclude-price a').on('click', function() {
var self = $(this);
doAdminAjax(
{
controller: help_class_name,
action: 'excludeProductsPrices',
token: $('input[name=token]').val(),
id: $(this).parents('tr').find('input[name="ximport_productBox[]"]').val(),
ajax: true
},
function(response)
{
var data = $.parseJSON(response);
showSuccessMessage(data.confirmations);
changeStatus(self);
}
);
return false;
});
};
changeStatus = function (object) {
//Prestashop 1.5
if (object.find('img').length) {
var status = object.find('img').attr('src').split('/');
if (status[3] === 'enabled.gif') {
object.attr('title', 'Wyłączone')
.children('img')
.attr('src', '../img/admin/disabled.gif')
.attr('title', 'Wyłączone')
.blur();
}
else {
object.attr('title', 'Włączone')
.children('img')
.attr('src', '../img/admin/enabled.gif')
.attr('title', 'Włączone')
.blur();
}
}
// bootstrap
else {
if (object.hasClass('action-disabled')) {
object.removeClass('action-disabled')
.addClass('action-enabled')
.children('.icon-check').removeClass('hidden')
.siblings('.icon-remove').addClass('hidden');
}
else if (object.hasClass('action-enabled')) {
object.removeClass('action-enabled')
.addClass('action-disabled')
.children('.icon-remove').removeClass('hidden')
.siblings('.icon-check').addClass('hidden');
}
object.blur();
}
};
return self;
}
})(jQuery);