console.log();
let ps_table = null;
let ps_list = null;
function psTable(list){
ps_list = list;
if(ps_list.length > 0){
let html_content = '';
let index = 0;
ps_list.forEach(function(installation){
let insturl = installation.hasOwnProperty('url') ? installation.url : 'http://' + installation.domain;
let dbinf = '';
if(installation.hasOwnProperty('db_result') && installation.db_result.result != 'success'){
let dbtitle = '{{langmod.ADDDBNOT}}: ' + handleDBError(installation.db_result.code);
dbinf = '' +
'' +
'' +
'';
}
html_content += '
' +
'' + installation.domain + ' ' +
'' + insturl + ' | ' +
'' + installation.path + ' | ' +
'' + installation.version + ' | ' +
'' + installation.lang + ' | ' +
'' +
'' +
' {{langmod.ADDSHORTDB}}: ' + installation.psbd + ' {{langmod.ADDSHORTUDB}}: ' + installation.psuserdb + ' ' +
dbinf +
' ' +
' | ' +
'' +
'' +
' | ' +
'
';
index++;
});
let table_html = '' +
'' +
'' +
'{{langmod.ADDDOMLAB}} | ' +
'{{langmod.ADDPATHLAB}} | ' +
'{{langmod.ADDVERLAB}} | ' +
'{{langmod.ADDLANGLAB}} | ' +
'{{langmod.ADDBDUDB}} | ' +
' | ' +
'
' +
'' +
'' +
html_content +
'' +
'
';
$('#table_ps_container').html(table_html);
$('.ps-table').DataTable().destroy();
ps_table = $('.ps-table').DataTable();
}else{
$('#table_ps_container').html('Thre\'s not Prestashop installations
');
}
$('[data-toggle="tooltip"]').tooltip();
}
function psInit(){
if(ps_list == null){
psReList();
}
}
function psReList(){
$('#table_ps_container').html(loader);
getList('prestashop', function(response){
psTable(response);
});
}
function cancelPS(idCollapse){
uchip.slideToggle('#ps_list','#ps_form', function(){
});
$('#psdomain').val('');
$('#pspach').val('ps');
$('#psadminemail').val('');
$('#psadminpass').val('');
$('#psadminpass').pwstrength('forceUpdate');
$('#pspassbd').val('');
$('#pspassbd').pwstrength('forceUpdate');
$('#pslang').val('en');
$('#psversion').val('1.7');
$('#psbd').val('ps{{mod.extra_data.randbd}}');
$('#psuserdb').val('ps{{mod.extra_data.randbd}}');
uchip.validator('.reqps', true);
cancelGeneral(idCollapse);
}
function addPrestaShop(){
if(uchip.validator('.reqps')){
let psurl = $("#psurl").val();
let psdomain = $("#psdomain").val();
let pslang = $("#pslang").val();
let psbd = $("#psbd").val();
let psuserdb = $("#psuserdb").val();
let pspassbd = $("#pspassbd").val();
let pspach = $("#pspach").val();
let psversion = $("#psversion").val();
let psadminemail = $("#psadminemail").val();
let psadminpass = $("#psadminpass").val();
let dompath = $('#psdomain option:selected').data('path');
let domssl = $('#psdomain option:selected').data('ssl');
let data = 'psurl=' + psurl + '&psdomain=' + psdomain + '&pslang=' + pslang + '&psbd=' + psbd + '&psuserdb=' + psuserdb + '&pspassbd=' + Base64.encode(pspassbd) +
'&pspach=' + pspach + '&psversion=' + psversion + '&psadminemail=' + psadminemail + '&psadminpass=' + Base64.encode(psadminpass) + '&dompath=' + dompath + '&domssl=' + domssl;
let details = [
{
title : '{{langmod.ADDDOMLAB}}',
value : psdomain
},
{
title : '{{langmod.ADDURLLAB}}',
value : (domssl == 1 ? 'https' : 'http') + '://' + psdomain + '/' + pspach
},
{
title : '{{langmod.ADDPATHLAB}}',
value : dompath + '/' + pspach
},
{
title : '{{langmod.ADDPS03}}',
value : psadminemail
},
{
title : '{{langmod.ADDVERLAB}}',
value : psversion
},
{
title : '{{langmod.ADDLANGLAB}}',
value : pslang
},
{
title : '{{langmod.ADDDWP20}}',
value : psbd
},
{
title : '{{langmod.ADDDBUSERLAB}}',
value : psuserdb
}
];
confirmInstallation({
type: 'prestashop',
script: 'Prestashop',
data : data,
wholepath: dompath + '/' + pspach,
callback: function(response){
if(response.hasOwnProperty('result') && response.result == 'success'){
if(response.db_result.result != 'success'){
noti_bubble('{{langmod.ADDINSTALLDET}} ' + handleDBError(response.db_result.code),'{{langmod.ADDATENTION}}!','warning',false,false,'6500',true);
}else{
noti_bubble('{{langmod.ADDINSTALLSUCC}}','{{langmod.SUCCESS}}','success',false,false,'3000',true);
}
}else{
noti_bubble('{{langmod.ADDERRORGEN}}','{{langmod.FERROR}}','error',false,false,'3000',true);
}
var variableHTML='';
var modulin='ps';
if($("#instaled_"+modulin).html()==undefined){
variableHTML+=''
$( "#accordion1" ).append( variableHTML );
$(".accordion-toggle").click(function(){
$("#"+$(this).prop('data-target')).slideToggle('slow');
});
}
$("#instaledEmpty").hide();
psTable(response.list);
cancelPS();
},
details: details
});
}else{
noti_bubble('{{langmod.ADDREQFIELDS}}','{{langmod.FERROR}}','error',false,false,'3000',true);
}
}