let mag_table = null;
let mag_list = null;
function magTable(list){
mag_list = list;
if(mag_list.length > 0){
let html_content = '';
let index = 0;
mag_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 + ' | ' +
'' +
'' +
' {{langmod.ADDSHORTDB}}: ' + installation.magbd + ' {{langmod.ADDSHORTUDB}}: ' + installation.maguserdb + ' ' +
dbinf +
' ' +
' | ' +
'' +
'' +
' | ' +
'
';
index++;
});
let table_html = '' +
'' +
'' +
'{{langmod.ADDDOMLAB}} | ' +
'{{langmod.ADDPATHLAB}} | ' +
'{{langmod.ADDVERLAB}} | ' +
'{{langmod.ADDBDUDB}} | ' +
' | ' +
'
' +
'' +
'' +
html_content +
'' +
'
';
$('#table_mag_container').html(table_html);
$('.mag-table').DataTable().destroy();
mag_table = $('.mag-table').DataTable();
}else{
$('#table_mag_container').html('Thre\'s not Magento installations
');
}
$('[data-toggle="tooltip"]').tooltip();
}
function magInit(){
if(mag_list == null){
magReList();
}
}
function magReList(){
$('#table_mag_container').html(loader);
getList('magento', function(response){
magTable(response);
});
}
function cancelMag(idCollapse){
uchip.slideToggle('#mag_list','#mag_form', function(){
});
$('#magdomain').val('');
$('#magpach').val('mag');
$('#magadminemail').val('');
$('#magadminpass').val('');
$('#magadminpass').pwstrength('forceUpdate');
$('#magpassbd').val('');
$('#magpassbd').pwstrength('forceUpdate');
$('#magbd').val('mag{{mod.extra_data.randbd}}');
$('#maguserdb').val('mag{{mod.extra_data.randbd}}');
uchip.validator('.reqmag', true);
cancelGeneral(idCollapse);
}
function addMagento(){
if(uchip.validator('.reqmag')){
let p = $("#magadminpass").val();
if (p.search(/[a-z]/i) < 0) {
noti_bubble('Your password must include both numeric and alphabetic characters.','{{langmod.FERROR}}','error',false,false,'3000',true);
return false
}
if (p.search(/[0-9]/) < 0) {
noti_bubble('Your password must include both numeric and alphabetic characters.','{{langmod.FERROR}}','error',false,false,'3000',true);
return false
}
let magurl = $("#magurl").val();
let magdomain = $("#magdomain").val();
let magbd = $("#magbd").val();
let maguserdb = $("#maguserdb").val();
let magpassbd = $("#magpassbd").val();
let magpach = $("#magpach").val();
let magadminemail = $("#magadminemail").val();
let magadminpass = $("#magadminpass").val();
let magfolderadmin= $("#magfolderadmin").val();
let magadminuser= $("#magadminuser").val();
let dompath = $('#magdomain option:selected').data('path');
let domssl = $('#magdomain option:selected').data('ssl');
let data = 'magadminuser='+magadminuser+'&magfolderadmin='+magfolderadmin+'&magurl=' + magurl + '&magdomain=' + magdomain + '&magbd=' + magbd + '&maguserdb=' + maguserdb + '&magpassbd=' + Base64.encode(magpassbd) +
'&magpach=' + magpach + '&magadminemail=' + magadminemail + '&magadminpass=' + Base64.encode(magadminpass) + '&dompath=' + dompath + '&domssl=' + domssl;
let details = [
{
title : '{{langmod.ADDDOMLAB}}',
value : magdomain
},
{
title : '{{langmod.ADDURLLAB}}',
value : (domssl == 1 ? 'httmag' : 'http') + '://' + magdomain + '/' + magpach
},
{
title : '{{langmod.ADDPATHLAB}}',
value : dompath + '/' + magpach
},
{
title : '{{langmod.ADDPS03}}',
value : magadminemail
},
{
title : '{{langmod.ADDDWP20}}',
value : magbd
},
{
title : '{{langmod.ADDDBUSERLAB}}',
value : maguserdb
}
];
confirmInstallation({
type: 'magento',
script: 'Magento',
data : data,
wholepath: dompath + '/' + magpach,
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='mag';
if($("#instaled_"+modulin).html()==undefined){
variableHTML+=''
$( "#accordion1" ).append( variableHTML );
$(".accordion-toggle").click(function(){
$("#"+$(this).prop('data-target')).slideToggle('slow');
});
}
$("#instaledEmpty").hide();
magTable(response.list);
cancelMag();
},
details: details
});
}else{
noti_bubble('{{langmod.ADDREQFIELDS}}','{{langmod.FERROR}}','error',false,false,'3000',true);
}
}