/**
* Sends JS errors to google analytics
* Based on this answer: https://stackoverflow.com/a/21718577
*/
if (typeof window.onerror === 'object') {
window.onerror = function (err, url, line) {
if (typeof ga === "undefined") {
return;
}
var xentralModule,
xentralVersion;
if(document.body !== null && document.body.dataset !== undefined){
xentralModule = document.body.dataset.module;
xentralVersion = document.body.dataset.version;
}
ga('send', 'exception', {
'exDescription':
'xentral-module: ' + xentralModule +
' xentral-version: ' + xentralVersion +
' url: ' + url +
' line: ' + line +
' error: ' + err,
'appVersion': xentralVersion
});
};
}
document.head || (document.head = document.getElementsByTagName('head')[0]);
var aktlupe = null;
var lastlupe = null;
var blockclick = false;
function checkautocomplete()
{
$('.json_autocomplete').each(function() {
var jsontext = $(this).html();
if(jsontext) {
var obj = JSON.parse(jsontext);
if (typeof obj.data != 'defined' && typeof obj.element != 'undefined') {
$('#' + obj.element).autocomplete(obj.data);
}
$(this).remove();
}
});
$('.autocomplete_json').each(function() {
var jsontext = $(this).html();
if(jsontext) {
var json = JSON.parse(jsontext);
var obj = new Object();
obj.source = json.source;
if (typeof json.onlyfirst != 'undefined' && json.onlyfirst == '1') {
obj.select = function (event, ui) {
var i = ui.item.value;
var zahl = i.indexOf(" ");
var text = i.slice(0, zahl);
$("input#" + json.element).val(text);
return false;
}
}
if (typeof json.appendTo != 'undefined' && json.appendTo != '') {
obj.appendTo = "#" + json.appendTo;
}
if (typeof json.element != 'undefined') {
$("input#" + json.element).autocomplete(obj);
$(this).remove();
}
}
});
}
function generate(type, text) {
if(type === 'chatbox')
{
var anzchat = $('ul#topmenu').find('.chatbox').first().text();
if(anzchat != text)
{
$('ul#topmenu').find('.chatbox').first().text(text);
$('ul#topmenu').find('.chatbox').first().toggleClass('nachrichtenboxzahl_red', true);
changeFavicon("./themes/new/images/favicon/favicon_message.ico");
$('#shortcuticon').attr('href', "./themes/new/images/favicon/favicon_message.ico");
$('#favicon').attr('href', "./themes/new/images/favicon/favicon_message.ico");
$('ul#topmenu').find('.chatbox').first().toggleClass('nachrichtenboxzahl', false);
}
}
}
function LoadGeschaeftsbriefvorlage(sid,type)
{
//alert('s ' + sid + ' t ' + type);
$( "#geschaeftsbriefvorlage-confirm" ).dialog({
resizable: false,
height: "auto",
width: 400,
modal: true,
buttons: {
"OK": function() {
$.ajax({
url: 'index.php?module='+type+'&action=abschicken&cmd=getvorlage',
data: {sid: sid, type: type},
success: function(data) {
result = JSON.parse(data);
if(result.status==1)
{
$('input#betreff').val(result.subject);
$('textarea#text').ckeditor().editor.setData(result.body);
} else {
alert('Keine passende Vorlage gefunden. Bitte in den Geschaeftsbriefvorlagen definieren.');
}
}
});
$( this ).dialog( "close" );
},
Cancel: function() {
$( this ).dialog( "close" );
}
}
});
}
function openchatbox()
{
$('#chatpopupcontent').html('');
$('#chatpopup').dialog('open');
}
function clicklupe(el)
{
lastlupe = el;
}
function aktualisiereLupe()
{
$('.ui-autocomplete-input').each(function(){
if($(this).css('display') == 'none')
{
$(this).next('.autocomplete_lupe').hide();
} else {
$(this).next('.autocomplete_lupe').show();
}
});
}
function trimel(el)
{
$(el).val($(el).val().trim());
}
var table_filter = {
init: function() {
$('.table_filter').find('input[type="text"]').css({
width: 200
});
$('.table_filter').find('select').css({
padding: '5px',
width: 200,
'border-radius': 0
});
$('.table_filter').find('.smallInput').css({
width: 125
});
$('.table_filter').each(function() {
$(this).find('table').first().wrap('
';
htmlLink += '';
window.setTimeout(function() {
$('.dataTables_wrapper')
.find('input')
.first()
.parent()
.after(htmlLink);
}, 500);
$(this).find('input').on('keypress',function(event) {
if ( event.which == 13 ) {
table_filter.setParameters(data_filter);
event.preventDefault();
}
});
});
addDeleteInput('.table_filter');
},
setParameters: function(data_selector, dontReload) {
var container = $('fieldset[data-filter="'+data_selector+'"]');
var set = container.serialize();
if ( container.hasClass('open') ) {
set += '&filterIsOpen=1';
}
$.ajax({
url: 'index.php?module=ajax&action=tablefilter&do=setParameters&filter=' + data_selector,
data: set,
success: function(data) {
if (!dontReload) {
window.setTimeout(function() {
window.location.reload();
});
}
// Filter gesetzt... DataTable aktualisieren
}
});
},
getParameters: function(container) {
$.ajax({
url: 'index.php?module=ajax&action=tablefilter',
dataType: 'json',
data: {
do: 'getParameters',
filter: container.attr('data-filter')
},
success: function(data) {
var countSetFilters = 0;
if (data == null) {
return false;
}
if (typeof data.filter != 'undefined') {
delete data.filter;
}
if (typeof data.action != 'undefined') {
delete data.action;
}
if (typeof data.do != 'undefined') {
delete data.do;
}
if (typeof data.module != 'undefined') {
delete data.module;
}
var filterOpen = false;
if (typeof data.filterIsOpen != 'undefined' && data.filterIsOpen >= 1) {
filterOpen = true;
delete data.filterIsOpen;
}
$.each(data, function(key,value) {
var input = container.find('[name="'+key+'"]');
switch(input.attr('type')) {
case 'checkbox':
if (value.length > 0) {
input.prop('checked', true);
}
break;
default:
input.val(value);
break;
}
if (value.length > 0) {
countSetFilters++;
}
});
if (countSetFilters > 0) {
container.css({
display: 'block'
});
if (filterOpen) {
$('.table_filter_inner').css({
display: 'block'
});
container.addClass('open');
$('.sizeToggle').html('');
} else {
$('.table_filter_inner').css({
display: 'none'
});
$('.sizeToggle').html('');
}
container.find('.table_filter_hinweis').html('Achtung, es sind Filter aktiv!
');
}
}
});
},
addTop: function(data_selector) {
var container = $('fieldset[data-filter="'+data_selector+'"]');
var beforeHtml = '';
beforeHtml += '';
beforeHtml += '
';
beforeHtml += '
';
beforeHtml += '
';
beforeHtml += '
';
container
.find('.table_filter_inner')
.before(beforeHtml);
},
clearParameters: function(data_selector) {
var container = $('fieldset[data-filter="'+data_selector+'"]');
var set = container.serialize();
container.find('input[type="text"]').val('');
container.find('input[type="checkbox"]').prop('checked', false);
container.find('input[type="radio"]').prop('checked', false);
container.find('select option').prop('selected', false);
$.ajax({
url: 'index.php?module=ajax&action=tablefilter&do=clearParameters&filter=' + data_selector,
data: set,
success: function(data) {
// Filter gelöscht... DataTable aktualisieren
window.setTimeout(function() {
window.location.reload();
});
}
});
},
open: function(data_selector) {
var container = $('fieldset[data-filter="'+data_selector+'"]');
container.find('.iOpen').remove();
container.find('.table_filter_inner').css({
display: 'block'
});
},
sizeToggle: function(data_selector) {
var container = $('fieldset[data-filter="'+data_selector+'"]');
if (container.hasClass('open')) {
container.removeClass('open');
container.find('.table_filter_inner').css({
display: 'none'
});
container.find('.sizeToggle').html('');
} else {
container.addClass('open');
container.find('.table_filter_inner').css({
display: 'block'
});
container.find('.sizeToggle').html('');
}
table_filter.setParameters(data_selector, true);
},
toggle: function(data_selector) {
var container = $('fieldset[data-filter="'+data_selector+'"]');
if (container.hasClass('smallPreview')) {
table_filter.open(data_selector);
return true;
}
if (container.is(':visible')) {
container.slideUp();
container.removeClass('open');
} else {
container.slideDown();
container.addClass('open');
}
}
};
var App = {
loading: {
open: function(callback) {
if ( $('.loader_app').length == 0 ) {
App.loading.create();
}
if (typeof callback == 'function') {
callback();
}
$('.loader_app').show();
},
close: function() {
$('.loader_app').hide();
},
create: function() {
$('#scroller2').append('');
}
}
};
$(document).ready(function() {
$('.table_filter').css({
display: 'none'
});
table_filter.init();
});
/**
* Vorgangspositionen > Artikelsuche: Keine Ergebnisse + ENTER-Taste > Profisuche öffnen
*/
$(document).ready(function () {
var artikelAutoCompleteResultCount = 0;
var $artikelAutoComplete = $('#tableone #artikel');
// Wir befinden uns nicht in den Vorgangspositionen > Nichts tun
if ($artikelAutoComplete.length === 0) {
return;
}
// Merken wieviele Artikel gefunden wurden
$artikelAutoComplete.on('autocompleteresponse', function (event, ui) {
artikelAutoCompleteResultCount = typeof ui.content !== 'undefined' && ui.content !== null ? ui.content.length : 0;
});
// Profisuche öffnen, wenn es keine Ergebnisse gibt und ENTER gedrückt wird
$artikelAutoComplete.on('keydown', function (e) {
if (typeof e.keyCode !== 'undefined' && e.keyCode === 13) { // 13 = ENTER
// Es wurde ein Artikel eingegeben, es gibt aber keine Ergebnisse > Profisuche öffnen
var artikelAutocompleteValue = $artikelAutoComplete.val();
if (artikelAutocompleteValue !== '' && artikelAutoCompleteResultCount === 0) {
e.preventDefault();
var $artikelProfisucheButton = $('#artikel-profisuche-button');
var location = $artikelProfisucheButton.data('location');
// Profisuche öffnen
if (typeof location === 'undefined' || location === 'undefined') {
// Suchbegriff fehlt > Profisuche einfach öffnen
$artikelProfisucheButton.trigger('click');
} else {
// Suchbegriff in Profisuche übernehmen
location += '&name_de=' + artikelAutocompleteValue;
window.location.href = location;
}
}
}
});
});
/**
* Vorgangspositionen > Profisuche: Bei Drücken der ESC-Taste zurück zu den Positionen
*/
$(document).ready(function() {
// Wir befinden uns nicht in der Profisuche > Nichts tun
if ($('#profisuche-back-button').length === 0) {
return;
}
// Bei ESC > Zurück-Button auf Seite anklicken
$(document).on('keyup', function (e) {
if (typeof e.keyCode !== 'undefined' && e.keyCode === 27) {
document.getElementById('profisuche-back-button').click();
}
});
});
/**
* Vorgangspositionen > Profisuche: Individueller Steuersatz ein-/ausblenden
*/
$(document).ready(function() {
// Wir befinden uns nicht in der Profisuche > Nichts tun
if ($('#steuersatz-individuell-switch').length === 0) {
return;
}
var $customTaxRateContainer = $('#steuersatz-individuell-container');
var $customTaxRateInput = $('#steuersatz-individuell');
var $customTaxRateSwitch = $('#steuersatz-individuell-switch');
var $taxRateDropdown = $('#umsatzsteuerauswahl');
// Funktion prüft anhand von Checkbox ob Eingabefeld ein- oder ausgeblendet werden soll
var toggleCustomTaxRateInput = function () {
var customTaxRateActive = $customTaxRateSwitch.prop('checked');
$customTaxRateContainer.toggle(customTaxRateActive);
if (customTaxRateActive === false) {
$customTaxRateInput.val('');
$taxRateDropdown.prop('disabled', false);
} else {
$taxRateDropdown.prop('disabled', true);
}
};
// Einmal prüfen wenn Seite geladen wird
toggleCustomTaxRateInput();
// Bei jeder Änderung der Checkbox erneut prüfen
$(document).on('change', '#steuersatz-individuell-switch', function () {
toggleCustomTaxRateInput();
});
});
(function() {
if (window.matchMedia) {
var mediaQueryList = window.matchMedia('print');
mediaQueryList.addListener(function(mql) {
if (mql.matches) {
beforePrint();
} else {
afterPrint();
}
});
}
window.onbeforeprint = beforePrint;
window.onafterprint = afterPrint;
}());
function beforePrint() {
/*
$('.mce-edit-area iframe').each(function() {
$(this).attr('original-height', $(this).height());
$(this).height($(this).contents().find("html").height());
});
*/
}
function afterPrint() {
$(this).height($(this).attr('original-height'));
}
function wawisionPrint() {
App.loading.open();
$('.mce-edit-area iframe').each(function() {
$(this).attr('original-height', $(this).height());
$(this).height( $(this).contents().find("html").height() );
});
window.setTimeout(function() {
window.print();
App.loading.close();
window.setTimeout(function() {
$('.mce-edit-area iframe').each(function() {
$(this).height( $(this).attr('original-height') );
});
}, 500);
}, 500);
}
function printdiv(iddiv)
{
var divToPrint=document.getElementById(iddiv);
var newWin=window.open('','Print-Window');
newWin.document.open();
newWin.document.write(''+divToPrint.innerHTML+'');
newWin.document.close();
setTimeout(function(){newWin.close();},10);
}
function addDeleteInput(selector) {
$(selector).find('input[type="text"]').wrap('