Add JS files
This commit is contained in:
111
modules/EcmSysInfos/js/headersDocuments.js
Executable file
111
modules/EcmSysInfos/js/headersDocuments.js
Executable file
@@ -0,0 +1,111 @@
|
||||
$(document).ready(function () {
|
||||
CKEDITOR.replace('header1');
|
||||
CKEDITOR.replace('footer1');
|
||||
var id = $('#docselect option:selected').val();
|
||||
var language = $('#languageselect option:selected').val();
|
||||
$('#languageselect').on('change', getDocListForLanguage);
|
||||
CKEDITOR.instances['header1'].setData(getCodeHeader(id, language));
|
||||
CKEDITOR.instances['footer1'].setData(getCodeFooter(id, language));
|
||||
$('#invoice_number_format').val(getInvoiceNumberFormat(id));
|
||||
$('#invoice_number_format').change(function () {
|
||||
var value = $('#invoice_number_format').find(":selected").text();
|
||||
if (value == 'Nistandardowe') {
|
||||
$('#custom_number_format').show();
|
||||
} else {
|
||||
$('#custom_number_format').hide();
|
||||
$('#custom_number_format').val('');
|
||||
}
|
||||
});
|
||||
$('#docselect').change(function () {
|
||||
var id = $('#docselect option:selected').val();
|
||||
CKEDITOR.instances['header1'].setData(getCodeHeader(id, language));
|
||||
CKEDITOR.instances['footer1'].setData(getCodeFooter(id, language));
|
||||
$('#invoice_number_format').val(getInvoiceNumberFormat(id));
|
||||
$('#custom_number_format').hide();
|
||||
$('#custom_number_format').val('');
|
||||
});
|
||||
});
|
||||
|
||||
function getCodeHeader(request, language) {
|
||||
var tmp = null;
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "index.php?module=EcmSysInfos&action=dbpost&to_pdf=1",
|
||||
dataType: "html",
|
||||
async: false,
|
||||
data: {
|
||||
job: "getCodeHeader",
|
||||
id: request,
|
||||
language: language,
|
||||
},
|
||||
success: function (data) {
|
||||
tmp = data;
|
||||
}
|
||||
});
|
||||
return tmp;
|
||||
}
|
||||
|
||||
function getCodeFooter(request, language) {
|
||||
var tmp = null;
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "index.php?module=EcmSysInfos&action=dbpost&to_pdf=1",
|
||||
dataType: "html",
|
||||
async: false,
|
||||
data: {
|
||||
job: "getCodeFooter",
|
||||
id: request,
|
||||
language: language,
|
||||
},
|
||||
success: function (data) {
|
||||
tmp = data;
|
||||
}
|
||||
});
|
||||
return tmp;
|
||||
}
|
||||
|
||||
function getInvoiceNumberFormat(request) {
|
||||
var tmp = null;
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "index.php?module=EcmSysInfos&action=dbpost&to_pdf=1",
|
||||
dataType: "json",
|
||||
async: false,
|
||||
data: {
|
||||
job: "getInvoiceNumberFormat",
|
||||
id: request,
|
||||
},
|
||||
success: function (data) {
|
||||
tmp = data;
|
||||
}
|
||||
});
|
||||
return tmp;
|
||||
}
|
||||
|
||||
function getDocListForLanguage() {
|
||||
$("#docselect").empty();
|
||||
var tmp = null;
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "index.php?module=EcmSysInfos&action=dbpost&to_pdf=1",
|
||||
dataType: "json",
|
||||
async: false,
|
||||
data: {
|
||||
job: "getDocListForLanguage",
|
||||
language: $(this).val(),
|
||||
},
|
||||
success: function (data) {
|
||||
tmp = data;
|
||||
}
|
||||
});
|
||||
if (tmp != null) {
|
||||
$.each(tmp, function (index, key) {
|
||||
var option = $('<option></option>').attr("value", index).text(key);
|
||||
$("#docselect").append(option);
|
||||
});
|
||||
var id = $('#docselect option:selected').val();
|
||||
var language = $('#languageselect option:selected').val();
|
||||
CKEDITOR.instances['header1'].setData(getCodeHeader(id, language));
|
||||
CKEDITOR.instances['footer1'].setData(getCodeFooter(id, language));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user