let ost_table = null;
let ost_list = null;
function ostTable(list){
ost_list = list;
if(ost_list.length > 0){
let html_content = '';
let index = 0;
ost_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.ostbd + ' {{langmod.ADDSHORTUDB}}: ' + installation.ostuserdb + ' ' +
dbinf +
' ' +
' | ' +
'' +
'' +
' | ' +
'
';
index++;
});
let table_html = '' +
'' +
'' +
'{{langmod.ADDDOMLAB}} | ' +
'{{langmod.ADDPATHLAB}} | ' +
'{{langmod.ADDVERLAB}} | ' +
'{{langmod.ADDBDUDB}} | ' +
' | ' +
'
' +
'' +
'' +
html_content +
'' +
'
';
$('#table_ost_container').html(table_html);
$('.ost-table').DataTable().destroy();
ost_table = $('.ost-table').DataTable();
}else{
$('#table_ost_container').html('Thre\'s not osTicket installations
');
}
$('[data-toggle="tooltip"]').tooltip();
}
function ostInit(){
if(ost_list == null){
ostReList();
}
}
function ostReList(){
$('#table_ost_container').html(loader);
getList('osticket', function(response){
ostTable(response);
});
}
function cancelost(idCollapse){
uchip.slideToggle('#ost_list','#ost_form', function(){
});
$('#ostdomain').val('');
$('#ostpach').val('ost');
$('#ostadminemail').val('');
$('#ostadminpass').val('');
$('#ostadminpass').pwstrength('forceUpdate');
$('#ostpassbd').val('');
$('#ostpassbd').pwstrength('forceUpdate');
$('#ostbd').val('ost{{mod.extra_data.randbd}}');
$('#ostuserdb').val('ost{{mod.extra_data.randbd}}');
uchip.validator('.reqost', true);
cancelGeneral(idCollapse);
}
function addost(){
if(uchip.validator('.reqost')){
let osturl = $("#osturl").val();
let ostdomain = $("#ostdomain").val();
let ostbd = $("#ostbd").val();
let ostuserdb = $("#ostuserdb").val();
let ostpassbd = $("#ostpassbd").val();
let ostpach = $("#ostpach").val();
let ostadminemail = $("#ostadminemail").val();
let ostadminpass = $("#ostadminpass").val();
let ostfolderadmin= $("#ostfolderadmin").val();
let ostadminuser= $("#ostadminuser").val();
let dompath = $('#ostdomain option:selected').data('path');
let domssl = $('#ostdomain option:selected').data('ssl');
let data = 'ostadminuser='+ostadminuser+'&ostfolderadmin='+ostfolderadmin+'&osturl=' + osturl + '&ostdomain=' + ostdomain + '&ostbd=' + ostbd + '&ostuserdb=' + ostuserdb + '&ostpassbd=' + Base64.encode(ostpassbd) +
'&ostpach=' + ostpach + '&ostadminemail=' + ostadminemail + '&ostadminpass=' + Base64.encode(ostadminpass) + '&dompath=' + dompath + '&domssl=' + domssl;
let details = [
{
title : '{{langmod.ADDDOMLAB}}',
value : ostdomain
},
{
title : '{{langmod.ADDURLLAB}}',
value : (domssl == 1 ? 'http' : 'http') + '://' + ostdomain + '/' + ostpach
},
{
title : '{{langmod.ADDPATHLAB}}',
value : dompath + '/' + ostpach
},
{
title : '{{langmod.ADDPS03}}',
value : ostadminemail
},
{
title : '{{langmod.ADDDWP20}}',
value : ostbd
},
{
title : '{{langmod.ADDDBUSERLAB}}',
value : ostuserdb
}
];
confirmInstallation({
type: 'osticket',
script: 'osticket',
data : data,
wholepath: dompath + '/' + ostpach,
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='ost';
if($("#instaled_"+modulin).html()==undefined){
variableHTML+=''
$( "#accordion1" ).append( variableHTML );
$(".accordion-toggle").click(function(){
$("#"+$(this).prop('data-target')).slideToggle('slow');
});
}
$("#instaledEmpty").hide();
ostTable(response.list);
cancelost();
},
details: details
});
}else{
noti_bubble('{{langmod.ADDREQFIELDS}}','{{langmod.FERROR}}','error',false,false,'3000',true);
}
}