Add import API module files and templates
- Created front.js for handling frontend JavaScript functionalities. - Added index.php files for both the views and templates to manage redirection and access control. - Implemented configure.tpl for admin configuration settings with AJAX functionality for field retrieval. - Developed delete.tpl for product deletion with progress tracking. - Introduced file_upload.tpl for file upload handling with drag-and-drop support. - Created import.tpl for managing product imports with progress indicators. - Added list.tpl for displaying uploaded files with action links. - Implemented temp.tpl for queuing products with visual feedback. - Enhanced index.php for module access control. - Updated templates to include necessary JavaScript for AJAX operations and user interactions.
This commit is contained in:
193
modules/import_api/views/templates/admin/temp.tpl
Normal file
193
modules/import_api/views/templates/admin/temp.tpl
Normal 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>
|
||||
Reference in New Issue
Block a user