$(document).keyup(function(e) { if (e.key === "Escape") { // escape key maps to keycode `27` $("#mymodal").dialog( "close" ); } }); function printContent(el){ $(".tableFloatingHeaderOriginal").css("width","auto"); $(".tableFloatingHeaderOriginal").css("position",""); $(".tableFloatingHeader").css("display","none"); $("#vareliste").removeClass('stickyheader'); $("#vareliste th").css("min-width",""); $("#vareliste th").css("width","auto"); var restorepage = document.body.innerHTML; var printcontent = document.getElementById(el).innerHTML; document.body.innerHTML = printcontent; window.print(); document.body.innerHTML = restorepage; } function showinputtext(id){ document.getElementById(id).className = ""; } function hideinputtext(id){ document.getElementById(id).className = "hideinputtext"; } function createCookie(name,value,days) { if (days) { var date = new Date(); date.setTime(date.getTime()+(days*24*60*60*1000)); var expires = "; expires="+date.toGMTString(); } else var expires = ""; document.cookie = name+"="+value+expires+"; path=/"; } function readCookie(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for(var i=0;i < ca.length;i++) { var c = ca[i]; while (c.charAt(0)==' ') c = c.substring(1,c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); } return null; } function eraseCookie(name) { createCookie(name,"",-1); } $(document).on("click", ".ui-tabs-tab", function(event) { $("#modal_msg").hide(); }); $(document).on("click", ".faktg", function(event) { $(".tr_vare_selected").removeClass("tr_vare_selected"); snr = $(this).closest('tr').attr('data-href'); trid = $(this).closest('tr').attr('id'); //console.log(snr,trid); $(".tr_vare_selected").removeClass("tr_vare_selected"); $("#vareliste #"+trid).addClass("tr_vare_selected"); }); ////////////////////////notsure//////////////////////////// function fill(fieldid,pnr,type,dim,vareid) { $('#' + fieldid).val(pnr); $('#dim' + fieldid).val(dim); $('#type' + fieldid).val(type); $('#vareid' + fieldid).val(vareid); $('#display' + fieldid).hide(); } ////////////////////// $(document).on("click", ".clickable-row td:not(:last-child,.col_mark,.col_vedlegg)", function(event) { //clickable row in table opens modal dialog snr = $(this).closest('tr').attr('data-href'); trid = $(this).closest('tr').attr('id'); currsite=$('#getsite').attr('value'); //console.log(snr,trid); $(".tr_vare_selected").removeClass("tr_vare_selected"); $("#vareliste #"+trid).addClass("tr_vare_selected"); $.ajax({ type: "POST", url: "./ajax.php", data: { todo: 'get_dialogtitle', snr: snr, currsite: currsite }, success: function(html) { //if(currsite=='divservice'){acontent='tab_divservice&divid';} //else{acontent='vis_service&snr';} //$("#modal-body").load('ajax.php?content=' + acontent + '=' + snr, //$("#modal-body").load('ajax.php?content=vis_service&snr=' + snr, $("#modal-body").load('ajax.php?content=vis_service&snr=' + snr + '&currsite=' + currsite, function(){ var wHeight = $(window).height(); if(wHeight<1050){ maxH=wHeight-50; $("#mymodal").dialog({ width: 710, maxHeight: maxH, title: html, close: function() { $(".tr_vare_selected").removeClass("tr_vare_selected"); } }); } else { $("#mymodal").dialog({ width: 710, maxHeight: 1000, title: html, close: function() { $(".tr_vare_selected").removeClass("tr_vare_selected"); } }); } var wWidth = $(window).width(); if(wWidth<700){ $("#mymodal").dialog("option","draggable",false); } }); }//success end });//ajax end }); //clickable-row function end $(document).on("click", ".modalopen", function(event) { //link on site opens modal dialog event.preventDefault(); content = $(this).attr('data-href'); currsite = $('#getsite').attr('value'); divid = $(this).attr('divid'); if(divid>0){currsite = 'divservice';} console.log(divid); title = $(this).attr('title'); //console.log(content); $.ajax({ type: "GET", url: "./ajax.php", data: { site: content, }, success: function(html) { $("#modal-body").load('ajax.php?content=' + content + '&currsite=' + currsite + '&divid=' + divid, function(){ var wHeight = $(window).height(); if(wHeight<1050){ maxH=wHeight-50; $("#mymodal").dialog({ width: 710, maxHeight: maxH, title: title, close: function() { } }); } else { $("#mymodal").dialog({ width: 710, maxHeight: 1000, title: title, close: function() { } }); } var wWidth = $(window).width(); if(wWidth<700){ $("#mymodal").dialog("option","draggable",false); } }); }//success end });//ajax end }); //modalopen function end $(document).on("change", "#visperside", function(event) { //visperside change var getsite=$('#getsite').attr('value'); var url = window.location.href; var link = url.split('&'); //var link = $(this).closest('form').attr('action').split(/&(.+)/)[1]; var data = $(this).closest('form').serializeArray(); data.push({name: 'scripts', value: 'on'}); data.push({name: 'getsite', value: getsite}); $.ajax({ type: "POST", url: 'ajax.php?content=vareliste_table&'+link[1], data: data, success: function(html) { $("#vareliste_table").html(html).show(); }//success end });//ajax end }); //visperside function end $(document).on("change", "#selectmenu form", function(event) { //table menu select filters and reload table event.preventDefault(); var thissel = $(this).find(" :selected").val(); var thissel = $(this).find(" :checked").val(); var thistext = $(this).find('input[type=text]').val(); //console.log(thissel,thistext); if(thissel != '' && thissel != 'all' && thissel != 'NULL' && thissel != 'ja' && thissel != undefined | thistext != ''){ $(this).find('fieldset').addClass("filterselected"); } else { $(this).find('fieldset').removeClass("filterselected"); } var getsite=$('#getsite').attr('value'); var data = $(this).closest('form').serializeArray(); data.push({name: 'scripts', value: 'on'}); data.push({name: 'getsite', value: getsite}); //add page link here? $.ajax({ type: "POST", url: 'ajax.php?content=vareliste_table', data: data, success: function(html) { //$( '#vareliste_table').load(location.href + ' #vareliste_table','refresh=true'); $("#vareliste_table").html(html).show(); }//success end });//ajax end }); $(document).on("click", "#vareliste_table a:not(.col_pnr a), #varetelling a", function(event) { //links inside table area update only the table event.preventDefault(); //var loc = window.location.href; var url = $(this).attr('href').split(/&(.+)/)[1]; var getsite=$('#getsite').attr('value'); if(getsite=='varetelling') {window.location.hash = 'none'; } console.log(url,getsite); $.ajax({ type: "POST", data: { scripts: 'on', getsite: getsite }, url: 'ajax.php?content=vareliste_table&'+url, success: function(html) { $("#vareliste_table").html(html).show(); if(getsite=='varetelling') {window.location.hash = 'tbl';} }//success end });//ajax end }); $(document).ready(function(){ //doc ready begins $("#columnselect input:checkbox(:checked)").each(function() { var name = $(this).attr("name"); var column = "." + $(this).attr("name"); //console.log(column); $(column).show(); }); $("#columnselect input:checkbox:not(:checked)").each(function() { var name = $(this).attr("name"); var column = "." + $(this).attr("name"); $(column).hide(); }); $("#columnselect input:checkbox").click(function(){ var name = $(this).attr("name"); var column = "." + $(this).attr("name"); $(column).fadeToggle(500); if ( this.checked ) { var state = "show"; createCookie(name,state,10); } else { var state = "hide"; createCookie(name,state,10); } }); //save list var $checkboxes = $('.col_mark input[type="checkbox"]'); var arr = []; $checkboxes.change(function(){ if (this.checked) { arr.push(this.value); } else { arr.splice(arr.indexOf(this.value), 1); } $('#checked_ids').val(arr + ''); var countCheckedCheckboxes = $checkboxes.filter(':checked').length; $('#count-checked-checkboxes').text(countCheckedCheckboxes); if(countCheckedCheckboxes>0){ $("#marked_action").show(); } else { $("#list_details").hide(); $("#marked_action").hide(); } //$('#edit-count-checked-checkboxes').val(countCheckedCheckboxes); }); $('#marked_action').on('change', function() { if (this.value == 'save_list') { $("#list_details").show(); $("#list_addto").hide(); $("#list_removefrom").hide(); $('#input_list_name').attr('required', 'required'); } else if ( this.value == 'addto_list') { $("#list_details").hide();$("#list_addto").show();$("#list_removefrom").hide();$('#input_list_name').removeAttr('required'); } else if ( this.value == 'removefrom_list') { $("#list_details").hide();$("#list_addto").hide();$("#list_removefrom").show();$('#input_list_name').removeAttr('required'); } else { $("#list_details").hide();$("#list_addto").hide();$("#list_removefrom").hide();$('#input_list_name').removeAttr('required'); } }); //levering $(".levering_searchid").keyup(function() { var id = $(this).attr("id"); var findid = $('#' + id).val(); if (findid == "") { $("#display" + id).html(""); } else { $.ajax({ type: "POST", url: "levering_findid.php", data: { notid: findid, fieldid: id }, success: function(html) { $("#display" + id).html(html).show(); } }); } }); $('.levchecktype').on('change',function(){ var id = $(this).attr('tid'); var notid = $('#notid' + id).val(); //console.log(id); if($(this).val()==''){ $("#display" + id).show(); } else { $("#display" + id).hide(); } }); }); //doc ready end /////////////////////////////////////////////////////////////////////////////// hurtigredigering //////////////////////////// $(document).on("change", ".editingcheck", function(event) { //editing on/off change var getsite=$('#getsite').attr('value'); var editing=$(this).val(); var page = $('#currentpage').attr('value'); var url = window.location.href; var search = $('#sfield').val(); var link = url.split('&'); //console.log(link[1]); var data = $(this).closest('form').serializeArray(); data.push({name: 'scripts', value: 'on'}); data.push({name: 'editing', value: editing}); data.push({name: 'page', value: page}); data.push({name: 'getsite', value: getsite}); data.push({name: 'search', value: search}); $.ajax({ type: "POST", url: 'ajax.php?content=vareliste_table&'+link[1], data: data, success: function(html) { $("#vareliste_table").html(html).show(); }//success end });//ajax end }); //visperside function end $(document).on("change", ".editfield", function() { var getsite=$('#getsite').attr('value'); var repid = $(this).closest('tr').attr('data-repid'); var pnr = $(this).closest('tr').attr('data-pnr'); var snr = $(this).closest('tr').attr('data-snr'); var field = $(this).attr('name'); var value = $(this).val(); //console.log(thiscellid,cellaboveid,field,value); if (value=='nei') {value='';} if (value=='-') {value='';} $(this).addClass("savedinput"); $.ajax({ //ajax type: "POST", url: "quickedit.php", data: { username: '', pnr: pnr, repid: repid, snr: snr, field: field, value: value }, success: function(html) { /* var page = $('#currentpage').attr('value'); $.ajax({ type: "POST", url: 'ajax.php?content=vareliste_table', data: {scripts: 'on', getsite: getsite, page: page}, success: function(html) { $("#vareliste_table").html(html).show(); }//success2 end });//ajax2 end */ $("#quickedit_message").html(html).show(); }//success end });//ajax end }); /////////// hurtigredigering end //////////////////////////// $(document).ready(function(){ $(".datepicker").attr("autocomplete", "off"); $(".datefieldedit").attr("autocomplete", "off"); $('.showusermenu').click(function(event) { $('#user_menu').toggle(); event.preventDefault(); }); if($(window).width() < 1300){} else { $(".stickyheader").stickyTableHeaders(); $("#vareliste th").css("min-width",""); } $( ".datepicker" ).datepicker({ showWeek: true, dateFormat: "dd/mm/yy", firstDay: 1, dayNamesMin: [ "Sø", "Ma", "Ti", "On", "To", "Fr", "Lø" ], monthNames: [ "Januar", "Februar", "Mars", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "December" ], showButtonPanel: "true", showAnim: "" }); $( ".datefieldedit" ).datepicker({ showWeek: true, dateFormat: "d/M-y", firstDay: 1, dayNamesMin: [ "Sø", "Ma", "Ti", "On", "To", "Fr", "Lø" ], monthNamesShort: [ "jan", "feb", "mar", "apr", "mai", "jun", "jul", "aug", "sept", "okt", "nov", "des" ], monthNames: [ "Januar", "Februar", "Mars", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "December" ], showButtonPanel: "true", showAnim: "" }); }); //doc ready end