function anexosGED() {
var myLoading1 = FLUIGC.loading('#tableAnexosGED');
myLoading1.show();
var that = this;
var idPastaPai = 20429; /* Pasta GED/TMOV */
// Identifica pasta pai
var c1 = DatasetFactory.createConstraint("documentPK.companyId", $("#CODCOLIGADA").val(), $("#CODCOLIGADA").val(), ConstraintType.MUST);
var c2 = DatasetFactory.createConstraint("parentDocumentId", idPastaPai, idPastaPai, ConstraintType.MUST);
var c3 = DatasetFactory.createConstraint("documentType", "1", "1", ConstraintType.MUST);
var c4 = DatasetFactory.createConstraint("deleted", false, false, ConstraintType.MUST);
var c5 = DatasetFactory.createConstraint("activeVersion", true, true, ConstraintType.MUST);
var c6 = DatasetFactory.createConstraint("documentDescription", $("#IDMOV").val(), $("#IDMOV").val(), ConstraintType.MUST);
var fields = new Array("documentPK.companyId", "parentDocumentId", "documentType", "deleted", "activeVersion", "documentPK.documentId", "documentPK.version", "documentDescription");
var sortingFields = new Array("documentPK.companyId", "parentDocumentId", "documentDescription");
var constraints = new Array(c1, c2, c3, c4, c5, c6);
var ds01 = DatasetFactory.getDataset("document", fields, constraints, sortingFields);
if (ds01.values.length > 0) {
for (var i = 0; i < ds01.values.length; i++) {
// Busca arquivos dentro da pasta pai
c1 = DatasetFactory.createConstraint("documentPK.companyId", ds01.values[i]["documentPK.companyId"], ds01.values[i]["documentPK.companyId"], ConstraintType.MUST);
c2 = DatasetFactory.createConstraint("parentDocumentId", ds01.values[i]["documentPK.documentId"], ds01.values[i]["documentPK.documentId"], ConstraintType.MUST);
c3 = DatasetFactory.createConstraint("documentType", "2", "2", ConstraintType.MUST);
c4 = DatasetFactory.createConstraint("deleted", false, false, ConstraintType.MUST);
c5 = DatasetFactory.createConstraint("activeVersion", true, true, ConstraintType.MUST);
fields = new Array("documentPK.companyId", "parentDocumentId", "documentType", "deleted", "activeVersion", "documentPK.documentId", "documentPK.version", "documentDescription");
sortingFields = new Array("documentPK.companyId", "parentDocumentId", "documentDescription");
constraints = new Array(c1, c2, c3, c4, c5);
var ds02 = DatasetFactory.getDataset("document", fields, constraints, sortingFields);
if (ds02.values.length > 0) {
that.mydata = [];
for (var j = 0; j < ds02.values.length; j++) {
that.mydata.push({
COMPANYID: ds02.values[j]["documentPK.companyId"],
DOCUMENTID: ds02.values[j]["documentPK.documentId"],
VERSION: ds02.values[j]["documentPK.version"],
DOCUMENTDESCRIPTION: ds02.values[j]["documentDescription"]
});
}
document.getElementById("textAnexo").innerHTML="* Marque a linha para visualizar o anexo.";
} else {
document.getElementById("textAnexo").innerHTML="Nenhum anexo encontrado!";
}
}
}
that.myTable = FLUIGC.datatable('#tableAnexosGED', {
dataRequest: that.mydata,
renderContent: '.templateAnexosGED',
limit: 30,
offset: 0,
patternKey: 'text',
limitkey: 'per_page',
offsetKey: 'page',
formatData: function(data) {
return data;
},
/*multiSelect: true,*/
classSelected: 'danger',
header: [{
'title': 'Coligada',
'size': '',
'display': false
}, {
'title': 'ID',
'size': '',
'display': false
}, {
'title': 'Versão',
'size': '',
'display': false
}, {
'title': 'Documento',
'size': 'col-xs-11 col-sm-11 col-md-11',
'display': true
}],
search: {
enabled: false
},
scroll: {
enabled: false,
target: ".tableAnexosGED",
onScroll: function() {
// DO SOMETHING
}
},
actions: {
enabled: false,
template: '.templateAnexosGED',
actionAreaStyle: 'col-xs-12 col-sm-12 col-md-12'
},
navButtons: {
enabled: false
},
draggable: {
enabled: false
},
}, function(err, data) {
if (err) {
FLUIGC.toast({
message: err,
type: 'danger'
});
}
});
that.myTable.on('fluig.datatable.loadcomplete', function() {
if (!that.tableData) {
that.tableData = that.myTable.getData();
}
});
// We can hide the message of loading
myLoading1.hide();
$("#tableAnexosGED").show();
// Exibe arquivo
$('#tableAnexosGED').on('click', '.linhaAnexosGED', function() {
var index = that.myTable.selectedRows()[0];
var selected = that.myTable.getRow(index);
if ( $("#MOBILE").val() == "Não" ) {
openDocument(selected.DOCUMENTID, selected.VERSION);
} else {
window.location.href = "fluig://http://fluig.junqueirarodas:8443/portal/p/1/ecmnavigation?app_ecm_navigation_doc=" + String(selected.DOCUMENTID);
}
})
}
function openDocument(docId, docVersion) {
var parentOBJ;
if (window.opener) {
parentOBJ = window.opener.parent;
} else {
parentOBJ = parent;
}
var cfg = {
url : "/ecm_documentview/documentView.ftl",
maximized : true,
title : "Anexo",
callBack : function() {
parentOBJ.ECM.documentView.getDocument(docId, docVersion);
},
customButtons : []
};
parentOBJ.ECM.documentView.panel = parentOBJ.WCMC.panel(cfg);
}