first commit

This commit is contained in:
2025-01-06 20:47:25 +01:00
commit 3bdbd78c2f
25591 changed files with 3586440 additions and 0 deletions

View File

@@ -0,0 +1,87 @@
{*
* 2007-2018 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2018 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*}
<div class="panel" id="tab-general">
<p>Source: {$file_name}</p>
<div style="min-height:20px">
<p id="api-loader" style="display:none"> Please wait while module read file
<span class="hidden-xs" >
<i class="icon-refresh icon-spin icon-fw"></i>
</span>
</p>
</div>
<button id="reload-fields">Reload file</button>
<a class="pull-right" href="{$import_link}">Go to import page</a>
</div>
<script type="text/javascript">
function find_fields() {
$.ajax({
url: '{$get_fields_link}',
type: 'post',
data: $('#tab-general :input'),
dataType: 'json',
beforeSend: function() {
$('#api-loader').show();
$('#configuration_form').hide();
$('#reload-fields').button('loading');
},
complete: function() {
$('#api-loader').hide();
$('#configuration_form').show();
$('#reload-fields').button('reset');
},
success: function(json) {
if(json['error']){
alert(json['error']);
} else {
$('.api_field').empty();
$('.api_field').append(new Option('--Please select--', 0));
$.each(json.field, function(key, value) {
$('.api_field').append(new Option(value, value));
});
}
$('#import_api_fields').val(json.fields);
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
}
$( document ).ready(function() {
{if !$file_settings.fields}
find_fields();
{/if}
});
$(document).delegate('#reload-fields', 'click', function() {
find_fields();
});
</script>

View File

@@ -0,0 +1,79 @@
{**
* NOTICE OF LICENSE
* With the purchase or the installation of the software in your application
* you accept the license agreement.
*
* You can not resell and redistribute this file.
*
* @author Dalibor Stojcevski <dal_sto@yahoo.com>
* @copyright 2019 Dalibor Stojcevski
* @license Dalibor Stojcevski
*}
<div class="panel">
<p>There are {$total} products from this file {$file_name}. Products will be deleted from prestashop. Press delete button only if you are sure that you don't need products from this file</p>
</div>
<div class="panel">
<div class="buttons">
<input type="button" value="Start delete" id="start-delete" data-loading-text="{l s='Deleting' mod='import_api'}" class="btn btn-primary api-delete" />
</div>
<div id="import-result" style="min-height:100px"></br>
<div class="progress">
<div class="progress-bar progress-bar-success progress-bar-striped" role="progressbar"
aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width:0%"></div>
</div>
<span>Deleted : </span> <span id="deleted-number">NA</span></br>
</div>
</div>
<script type="text/javascript">
var deleted = 0;
var global_limit = {$total};
$(document).delegate('#start-delete', 'click', function() {
$('#start-delete').button('loading');
$('#delete-number').html('');
deleteProducts();
});
function deleteProducts(){
$.ajax({
url: '{$get_import_link}&action=delete&token={$token}',
type: 'post',
data: $('#module_form').serialize(),
dataType: 'json',
beforeSend: function() {
$('#delete-number').html($('#delete-number').html() + ' /Please wait...');
},
complete: function() {
},
success: function(ret) {
session_processed = ret['products_deleted'];
createVisialProgress(ret);
if(ret['notice'] == 'time_out'){
deleteProducts();
} else {
$('#start-delete').button('reset');
}
},
error: function(xhr, ajaxOptions, thrownError) {
//alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
deleteProducts();
}
});
}
function createVisialProgress(ret){
deleted += ret['products_deleted'];
$('#deleted-number').html(deleted);
processed = deleted;
valeur = ( processed / global_limit ) * 100;
$('.progress-bar').css('width', valeur+'%').attr('aria-valuenow', valeur);
}
</script>

View File

@@ -0,0 +1,118 @@
{**
* NOTICE OF LICENSE
* With the purchase or the installation of the software in your application
* you accept the license agreement.
*
* You can not resell and redistribute this file.
*
* @author Dalibor Stojcevski <dal_sto@yahoo.com>
* @copyright 2019 Dalibor Stojcevski
* @license Dalibor Stojcevski
*}
<form id="attachment_form" class="defaultForm form-horizontal AdminAttachments" action="{$form_link}" method="post" enctype="multipart/form-data" novalidate="">
<input type="hidden" name="submitAddSource" value="1">
<div class="panel" id="fieldset_0">
<div class="panel-heading">
<i class="icon-paper-clip"></i>&nbsp;Add new source
</div>
<div class="form-wrapper">
<div class="form-group">
<label class="control-label col-lg-3">Enter link</label>
<div class="col-lg-4">
<div class="form-group">
<input type="text" id="name_2" name="import_api_link" class="" value="" >
</div>
</div>
</div>
<p>Or upload file</p>
<div class="form-group">
<label class="control-label col-lg-3">File</label>
<div class="col-lg-6">
<div class="form-group">
<div class="col-sm-6">
<input id="file" type="file" name="doc" class="hide">
<div class="dummyfile input-group">
<span class="input-group-addon"><i class="icon-file"></i></span>
<input id="file-name" type="text" name="doc" readonly="">
<span class="input-group-btn">
<button id="file-selectbutton" type="button" name="submitAddSource" class="btn btn-default">
<i class="icon-folder-open"></i> Add file </button>
</span>
</div>
</div>
</div>
</div>
</div>
</div><!-- /.form-wrapper -->
<div class="panel-footer">
<button type="submit" value="1" id="attachment_form_submit_btn" name="submitAddSource" class="btn btn-default pull-right">
<i class="process-icon-save"></i> Save
</button>
<a class="btn btn-default" id="attachment_form_cancel_btn" onclick="javascript:window.history.back();">
<i class="process-icon-cancel"></i> Cancel
</a>
</div>
</div>
</form>
<script type="text/javascript">
$(document).ready(function(){
$('#file-selectbutton').click(function(e) {
$('#file').trigger('click');
});
$('#file-name').click(function(e) {
$('#file').trigger('click');
});
$('#file-name').on('dragenter', function(e) {
e.stopPropagation();
e.preventDefault();
});
$('#file-name').on('dragover', function(e) {
e.stopPropagation();
e.preventDefault();
});
$('#file-name').on('drop', function(e) {
e.preventDefault();
var files = e.originalEvent.dataTransfer.files;
$('#file')[0].files = files;
$(this).val(files[0].name);
});
$('#file').change(function(e) {
if ($(this)[0].files !== undefined)
{
var files = $(this)[0].files;
var name = '';
$.each(files, function(index, value) {
name += value.name+', ';
});
$('#file-name').val(name.slice(0, -2));
}
else // Internet Explorer 9 Compatibility
{
var name = $(this).val().split(/[\\/]/);
$('#file-name').val(name[name.length-1]);
}
});
if (typeof file_max_files !== 'undefined')
{
$('#file').closest('form').on('submit', function(e) {
if ($('#file')[0].files.length > file_max_files) {
e.preventDefault();
alert('You can upload a maximum of files');
}
});
}
});
</script>

View File

@@ -0,0 +1,199 @@
{**
* NOTICE OF LICENSE
* With the purchase or the installation of the software in your application
* you accept the license agreement.
*
* You can not resell and redistribute this file.
*
* @author Dalibor Stojcevski <dal_sto@yahoo.com>
* @copyright 2019 Dalibor Stojcevski
* @license Dalibor Stojcevski
*}
<div class="panel">
<div class="form-group">
<label class="control-label col-lg-3" for="input-live-start">Start index</label>
<div class="col-lg-9">
<input type="text" name="import_api_live_start" id="input-live-start" value="0"/>
</div>
</div></br></br>
<div class="form-group">
<label class="control-label col-lg-3" for="input-live-limit">Number of products</label>
<div class="col-lg-9">
<input type="text" name="import_api_live_limit" id="input-live-limit" value="0"/>
</div>
</div>
<div class="buttons">
<input type="button" value="Start import" id="start-import" data-loading-text="{l s='Loading' mod='import_api'}" class="btn btn-primary api-import" />
</div>
<div id="import-result" style="min-height:100px"></br>
<div class="progress">
<div class="progress-bar progress-bar-success progress-bar-striped" role="progressbar"
aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width:0%"></div>
</div>
<span>Imported : </span> <span id="import-number">NA</span></br>
<span>Updated : </span><span id="update-number">NA</span></br>
<span>Total : </span><span id="total-number">NA</span></br>
</br></br>
<p> For cron job you should use link {$get_import_link|escape:'htmlall':'UTF-8'} </p>
</div>
</div>
<div class="panel">
<fieldset class="form-horizontal">
<legend>Test results</legend>
<div class="form-group">
<label class="control-label col-lg-3" for="input-index-test">Test start index</label>
<div class="col-lg-9">
<input type="text" name="import_api_start_index" id="input-index-test" value="0"/>
</div>
</div>
<div class="buttons">
<input type="button" value="Original import" id="view-raw" data-loading-text="{l s='Loading' mod='import_api'}" class="btn btn-primary api-test" />
<input type="button" value="After split" id="view-split" data-loading-text="{l s='Loading' mod='import_api'}" class="btn btn-primary api-test" />
<input type="button" value="After grouping" id="view-grouping" data-loading-text="{l s='Loading' mod='import_api'}" class="btn btn-primary api-test" />
<input type="button" value="After modification" id="view-modified" data-loading-text="{l s='Loading' mod='import_api'}" class="btn btn-primary api-test" />
</div>
<div id="test-result" style="min-height:500px"></div>
</fieldset>
</div>
<div class="panel">
<p> If you have imported products by mistake and they can't be updated. Or you just need to delete products from this file, go to <a href="{$delete_link}">Delete products page</a>
</div>
<script type="text/javascript">
var global_limit = 0;
var created = 0;
var updated = 0;
$(document).delegate('#start-import', 'click', function() {
$('#start-import').button('loading');
$('#import-number').html('');
$('#update-number').html('');
start = +($('#input-live-start').val());
global_limit = limit = +($('#input-live-limit').val());
created = 0;
updated = 0;
importProducts(start, limit);
});
function importProducts(start = 0, limit = 0){
$.ajax({
url: '{$get_import_link}&action=import&start=' + start + '&limit=' + limit,
type: 'post',
data: $('#module_form').serialize(),
dataType: 'json',
beforeSend: function() {
$('#import-number').html($('#import-number').html() + ' /Please wait...');
$('#update-number').html($('#update-number').html() + ' /Please wait...');
},
complete: function() {
},
success: function(ret) {
session_processed = ret['products_created'] + ret['products_updated'];
if(ret['notice'] == 'time_out'){
createVisialProgress(ret);
start = start + session_processed;
if (limit){
limit -= session_processed;
}
importProducts(start, limit);
} else if(ret['notice'] == 'missing'){
createVisialProgress(ret);
importProducts();
} else {
$('#start-import').button('reset');
}
},
error: function(xhr, ajaxOptions, thrownError) {
//alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
importProducts(start, limit);
}
});
}
function createVisialProgress(ret){
updated += ret['products_updated'];
created += ret['products_created'];
$('#import-number').html(created);
$('#update-number').html(updated);
processed = created + updated;
if(!global_limit){
global_limit = ret['total'];
$('#total-number').html(ret['total']);
}
if(global_limit){
valeur = ( processed / global_limit ) * 100;
$('.progress-bar').css('width', valeur+'%').attr('aria-valuenow', valeur);
}
}
$(document).delegate('.api-test', 'click', function() {
$.ajax({
url: '{$get_import_link}&action=test&id=' + $(this).attr('id') + '&start=' + $('#input-index-test').val(),
type: 'post',
data: $('#module_form').serialize(),
dataType: 'json',
beforeSend: function() {
$('#test-result').html('Please wait...');
$(".api-test").attr("disabled", true);
//$('.api-test').button('loading');
},
complete: function() {
//$('.api-test').button('reset');
$(".api-test").attr("disabled", false);
},
success: function(ret) {
if(ret['error'] !== undefined){
alert(ret['error']);
} else {
html = '';
$.each(ret,function(p, product){
html += jsonObjToHtml(product);
html += '</br><hr>';
});
$('#test-result').html(html);
}
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
});
function jsonObjToHtml(obj){
html = '';
$.each(obj, function(index, value){
if(Array.isArray(value)){
html += '<p><b>' + index + '</b></p>';
html += '<ul>';
$.each(value, function(i, v) {
if (v !== null && typeof (v) === 'object') {
html += jsonObjToHtml(v);
} else {
html += '<li>' + v + '</li>';
}
});
html += '</ul>';
} else if (value !== null && typeof (value) === 'object') {
html += '<p><b>' + index + '</b></p>';
html += jsonObjToHtml(value);
} else {
html += '<p><b>' + index + '</b>: ' + value + '</p>';
}
});
return html;
}
</script>

View File

@@ -0,0 +1,35 @@
<?php
/**
* 2007-2018 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2018 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
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,35 @@
{**
* NOTICE OF LICENSE
* With the purchase or the installation of the software in your application
* you accept the license agreement.
*
* You can not resell and redistribute this file.
*
* @author Dalibor Stojcevski <dal_sto@yahoo.com>
* @copyright 2019 Dalibor Stojcevski
* @license Dalibor Stojcevski
*}
<div class="panel">
<div class="table-responsive-row clearfix">
<table id="table-attachment" class="table attachment">
<thead>
<tr class="nodrag nodrop">
<th><span class="title_box">Name</span></th>
<th class="text-right"><span class="title_box">Action</span></th>
<th class="text-right"><span class="title_box">Enable / Disbale</span></th>
</tr>
</thead>
<tbody>
{foreach from=$files item=file}
<tr>
<td>{$file.name}</td>
<td class="text-right" style="padding:10px"><a href="{$file.process_link}">View</a></td>
<td class="text-right" style="padding:10px"><a href="{$file.change_status_link}">{$file.other_status_text}</a></td>
</tr>
</tbody>
{/foreach}
</table>
<p><a href="{$show_disabled_link}">Show disabled sources</a></p>
</div>
</div>

View File

@@ -0,0 +1,193 @@
{**
* NOTICE OF LICENSE
* With the purchase or the installation of the software in your application
* you accept the license agreement.
*
* You can not resell and redistribute this file.
*
* @author Dalibor Stojcevski <dal_sto@yahoo.com>
* @copyright 2019 Dalibor Stojcevski
* @license Dalibor Stojcevski
*}
<div class="panel">
{if !$products}
<p> You don't have queued products. It is good to make this process for better testing and view before import. But you can skip and press Start import</p>
<button class="btn btn-default" id="start-queue">Queue</button>
{/if}
<p id="api-loader" style="display:none"> Please wait while module queue products
<span class="hidden-xs" >
<i class="icon-refresh icon-spin icon-fw"></i>
</span>
</p>
{if $products}
<div class="card">
<h3 class="card-title">Products from file</h3>
<a class="btn btn-default" href="{$settings_link}">Change settings</a>
<p>{$file_name}</p>
<span id="show-info" style="display:none">Imported: <span id="import-number1"></span>, Updated: <span id="update-number1"></span></span>
<button class="btn btn-default" style="float:right;margin-bottom:10px;" id="start-import-selected">Import selected</button>
</div>
<div class="clearfix"></div>
<form id="form-json-api" method="POST">
<table id="example2" class="table table-bordered table-striped">
<thead>
<tr>
<th>#</th>
<th>Unique</th>
<th>Reference</th>
<th>Name</th>
<th>Price</th>
<th>Quantity</th>
<th>Brand</th>
<th>Action</th>
</tr>
</thead>
<tbody>
{foreach from=$products item=product}
<tr id="tr-{$product.id}">
<td><input type="checkbox" name="indx[]" value="{$product.indx}"/></td>
<td>{$product.indx}</td>
<td>{$product.reference}</td>
<td>{$product.name}</td>
<td>{$product.price}</td>
<td>{$product.quantity}</td>
<td>{$product.manufacturer}</td>
<td>
<a href="{$get_import_link}&index={$product.indx}" target="_blank" >Import</a>
<a href="{$get_import_link}&index={$product.indx}&action=view_one" target="_blank" >View</a>
</td>
</tr>
{/foreach}
</tbody>
</table>
</form>
{if $limit}
<p>There is limit ({$limit}) for queued products for better performance. If you want to show all press on link <a href="{$show_all_link}">Show all</a></p>
{/if}
{/if}
</div>
<script>
$(document).ready(function() {
$('#example2').dataTable({
select: {
style: 'os',
selector: 'td:first-child'
},
order: [[ 2, 'asc' ]]
});
});
function queueProducts(delete_queue = 0){
$.ajax({
url: '{$get_import_link}&queue=1',
type: 'post',
// dataType: 'json',
beforeSend: function() {
$('#start-queue').button('loading');
$('#api-loader').show();
},
complete: function() {
//$('#start-queue').button('reset');
$('#api-loader').hide();
},
success: function(ret) {
if (ret == '0') {
alert('No products found. Change settings and reload again');
} else {
location.reload();
}
return false;
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
}
{if $auto_queue}
queueProducts();
{/if}
$(document).delegate('#start-queue', 'click', function() {
queueProducts();
});
//najnovo
var global_limit = 0;
var created = 0;
var updated = 0;
$(document).delegate('#start-import-selected', 'click', function() {
$("#start-import-selected").attr("disabled", true);
$('#import-number1').html('');
$('#update-number1').html('');
start = 0
global_limit = limit = 0;
created = 0;
updated = 0;
importSelectedProducts();
});
function importSelectedProducts(start = 0, limit = 0){
$.ajax({
url: '{$get_import_link}&action=selected&from=admin',
type: 'post',
data: $('#form-json-api').serialize(),
dataType: 'json',
beforeSend: function() {
$('#show-info').show();
},
complete: function() {
},
success: function(ret) {
$.each( ret['processed'], function( key, value ) {
//$('#tr-' + value).remove();
$('#example2').DataTable().row('#tr-' + value).remove().draw();
});
createVisialProgress1(ret);
console.log(ret);
if(ret['notice'] == 'time_out'){
start = start + session_processed;
if (limit){
//limit -= session_processed;
}
importSelectedProducts();
} else if(ret['notice']) {
alert(ret['notice']);
//$('#import-number').html(ret['notice'] + ' /Trying again...');
///importProducts(start, limit);
$("#start-import-selected").attr("disabled", false);
} else {
$("#start-import-selected").attr("disabled", false);
}
},
error: function(xhr, ajaxOptions, thrownError) {
//alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
window.setTimeout(function(){
importSelectedProducts(start, limit);
}, 300);
//$("#start-import-selected").attr("disabled", false);
}
});
}
function createVisialProgress1(ret){
updated += ret['products_updated'];
created += ret['products_created'];
$('#import-number1').html(created);
$('#update-number1').html(updated);
}
</script>

View File

@@ -0,0 +1,35 @@
<?php
/**
* 2007-2018 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2018 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
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;