$(document).ready(function() { $("button").button(); $(':submit').button(); }); var posArray = new Array(4); posArray[0] = new Array(4); posArray[0]['amats']='valdes loceklis'; posArray[0]['amats_lv']='valdes loceklis'; posArray[0]['amats_ru']='valdes loceklis'; posArray[0]['amats_en']='valdes loceklis'; posArray[1] = new Array(4); posArray[1]['amats']='padomes loceklis'; posArray[1]['amats_lv']='padomes loceklis'; posArray[1]['amats_ru']='padomes loceklis'; posArray[1]['amats_en']='padomes loceklis'; posArray[2] = new Array(4); posArray[2]['amats']='pilnvarotā persona'; posArray[2]['amats_lv']='pilnvarotā persona'; posArray[2]['amats_ru']='pilnvarotā persona'; posArray[2]['amats_en']='pilnvarotā persona'; posArray[3] = new Array(4); posArray[3]['amats']='prokūrists'; posArray[3]['amats_lv']='prokūrists'; posArray[3]['amats_ru']='prokūrists'; posArray[3]['amats_en']='prokūrists'; function attachCombo(id) { $('#'+id).combobox2(); $('#'+id+"_combo").bind('blur',function() { if ( $('#'+id+"_combo").val()=="") { $('#'+id+' option').removeAttr('selected'); $('#'+id+' option:first-child').attr("selected",true); } }); } (function( $ ) { $.widget( "ui.combobox2", { _create: function() { var self = this, select = this.element.hide(), selected = select.children( ":selected" ), value = selected.val() ? selected.text() : ""; var input = this.input = $( "" ) .insertAfter( select ) .val( value ) .attr('id' ,select.attr('id')+'_combo') .autocomplete({ delay: 0, minLength: 0, source: function( request, response ) { var matcher = new RegExp( $.ui.autocomplete.escapeRegex(request.term), "i" ); response( select.children( "option" ).map(function() { var text = $( this ).text(); if ( this.value && ( !request.term || matcher.test(text) ) ) return { label: text.replace( new RegExp( "(?![^&;]+;)(?!<[^<>]*)(" + $.ui.autocomplete.escapeRegex(request.term) + ")(?![^<>]*>)(?![^&;]+;)", "gi" ), "$1" ), value: text, option: this }; }) ); }, select: function( event, ui ) { ui.item.option.selected = true; select.trigger('change'); self._trigger( "selected", event, { item: ui.item.option }); }, change: function( event, ui ) { if ( !ui.item ) { var matcher = new RegExp( "^" + $.ui.autocomplete.escapeRegex( $(this).val() ) + "$", "i" ), valid = false; select.children( "option" ).each(function() { if ( $( this ).text().match( matcher ) ) { this.selected = valid = true; select.trigger('change'); return false; } }); if ( !valid ) { // remove invalid value, as it didn't match anything $( this ).val( "" ); select.val( "" ); input.data( "autocomplete" ).term = ""; select.trigger('change'); return false; } } } }) .addClass( "ui-widget ui-widget-content ui-corner-left" ); input.data( "autocomplete" )._renderItem = function( ul, item ) { return $( "
" ) .data( "item.autocomplete", item ) .append( "" + item.label + "" ) .appendTo( ul ); }; this.button = $( "" ) .attr( "tabIndex", -1 ) .attr( "title", "Show All Items" ) .insertAfter( input ) .button({ icons: { primary: "ui-icon-triangle-1-s" }, text: false }) .removeClass( "ui-corner-all" ) .addClass( "ui-corner-right ui-button-icon" ) .click(function() { // close if already visible if ( input.autocomplete( "widget" ).is( ":visible" ) ) { input.autocomplete( "close" ); return; } // pass empty string as value to search for, displaying all results input.autocomplete( "search", "" ); input.focus(); }); $("combo_city_combo").bind('click',function() { }); }, destroy: function() { this.input.remove(); this.button.remove(); this.element.show(); $.Widget.prototype.destroy.call( this ); } }); })( jQuery ); (function( $ ) { $.widget( "ui.combobox", { _create: function() { var self = this, select = this.element.hide(), selected = select.children( ":selected" ), value = selected.val() ? selected.text() : ""; var input = this.input = $( "" ) .insertAfter( select ) .val( value ) .autocomplete({ delay: 0, minLength: 0, source: function( request, response ) { var matcher = new RegExp( $.ui.autocomplete.escapeRegex(request.term), "i" ); response( select.children( "option" ).map(function() { var text = $( this ).text(); if ( this.value && ( !request.term || matcher.test(text) ) ) return { label: text.replace( new RegExp( "(?![^&;]+;)(?!<[^<>]*)(" + $.ui.autocomplete.escapeRegex(request.term) + ")(?![^<>]*>)(?![^&;]+;)", "gi" ), "$1" ), value: text, option: this }; }) ); }, select: function( event, ui ) { ui.item.option.selected = true; self._trigger( "selected", event, { item: ui.item.option }); }, change: function( event, ui ) { if ( !ui.item ) { var matcher = new RegExp( "^" + $.ui.autocomplete.escapeRegex( $(this).val() ) + "$", "i" ), valid = false; select.children( "option" ).each(function() { if ( $( this ).text().match( matcher ) ) { this.selected = valid = true; return false; } }); if ( !valid ) { var count=0; var value=$(this).val(); $("#"+select.attr('id')+" option:first-child").attr("value",value); $("#"+select.attr('id')+" option").attr("selected",false); $("#"+select.attr('id')+" option:first-child").attr("selected",true); return false; } } } }) .addClass( "ui-widget ui-widget-content ui-corner-left" ); input.data( "autocomplete" )._renderItem = function( ul, item ) { return $( "" ) .data( "item.autocomplete", item ) .append( "" + item.label + "" ) .appendTo( ul ); }; this.button = $( "" ) .attr( "tabIndex", -1 ) .attr( "title", "Show All Items" ) .insertAfter( input ) .button({ icons: { primary: "ui-icon-triangle-1-s" }, text: false }) .removeClass( "ui-corner-all" ) .addClass( "ui-corner-right ui-button-icon" ) .click(function() { // close if already visible if ( input.autocomplete( "widget" ).is( ":visible" ) ) { input.autocomplete( "close" ); return; } // pass empty string as value to search for, displaying all results input.autocomplete( "search", "" ); input.focus(); }); }, destroy: function() { this.input.remove(); this.button.remove(); this.element.show(); $.Widget.prototype.destroy.call( this ); } }); })( jQuery ); function clearFormErrors() { $('td').removeClass('error_top'); $('td').removeClass('error_bottom'); $('.error').html(''); } function toggleFormField(id,state) { if ( (state=="true")||(state==true)) { $('#'+id+'_html').parent().show(); $('#'+id+'_label').parent().show(); $('#'+id+'_error_message').parent().show(); } else { $('#'+id+'_html').parent().hide(); $('#'+id+'_label').parent().hide(); $('#'+id+'_error_message').parent().hide(); } } function docDesc(id) { var options = {}; if (! $("#li_"+id).hasClass("active")) { $( "#choosedoc_right" ).toggle( "slide", options, 200 ); $(".choose_doctype li").removeClass("active"); $( "#choosedoc_right" ).html($( "#"+id+"_desc" ).html()); $("#li_"+id).addClass("active"); $( "#choosedoc_right" ).toggle( "slide", options, 500 ); } } //global variables var telcounter=0; var addrcounter=0; var accountcounter=0; //encode string function myencodeURI(text) { var str=encodeURI(text); return(str.replace(/&/g, '%26')); } function viewUsers() { sendParam('viewusers=true'); } function validateUser() { sendParam($('#update_user').serialize()); } function searchUsers() { poststr=($('#user_search').serialize()); sendParam(poststr); } function editUser(id) { sendParam("edituser="+id); } function cancelUpdateUser(id) { sendParam('cancelUpdateUser='+id); } function eprokurors_load() { $('#papildus_navigacija_p').show('blind',null, 1200); $('.debt_actions').contextMenu({ menu: 'debtorMenu',leftButton: true,disableRightButton:true}, function(action, el, pos) { debtor_actions(action,$(el).attr('id'));}); return true; } ///darbības ar parādnieku function debtor_actions(action,id) { switch (action) { case "edit": goToUpdateDebtorMainInfo(id); break; case "edit2": goToUpdateDebtorSd(id); break; case "calculate": newDocChooseSd(id); break; case "newdoc": sendParam('documents='+id+'&action=showall'); break; case "delete": deleteDebtor(id); break; } } function newDoc(id) { sendParam('documents='+id+'&action=showall'); } function attachCals() { $.datepicker.setDefaults($.datepicker.regional['']); $(".datepicker_control").datepicker($.datepicker.regional['lv']); $(".datepicker_control").datepicker('option', {changeMonth: true,changeYear: true}); } function attachCal(e,obj) { var index,tablename; if (obj != null) { $.datepicker.setDefaults($.datepicker.regional['']); //$("#"+obj.id).datepicker($.datepicker.regional['lv']); $("#"+obj.id).datepicker($.datepicker.regional['lv']); $("#"+obj.id).datepicker('option', {changeMonth: true,changeYear: true}); } else { $.datepicker.setDefaults($.datepicker.regional['']); $("#"+this.id).datepicker($.datepicker.regional['lv']); $("#"+this.id).datepicker('option', {changeMonth: true,changeYear: true}); } } function toggleCalculationDetails(id) { var selectedEffect = 'blind'; var options = {}; $("#ag"+id).toggle(selectedEffect,options,500); if($("#hr"+id).text()!='Paslēpt aprēķinu gaitu') $("#hr"+id).text('Paslēpt aprēķinu gaitu'); else $("#hr"+id).text('Parādīt aprēķinu gaitu'); } //form an ajax request function sendParam(poststr) { document.getElementById('body').style.cursor='wait'; $.ajax({ type: 'POST', dataType: "json", cache:false, data: poststr, processData: false, beforeSend: function(x) { if(x && x.overrideMimeType) { x.overrideMimeType("application/j-son;charset=UTF-8"); } }, url: "http://skjbirojs.lv:443/data/process.php", error:function(x,e){ console.log(x); if(x.status==0) { alert('Pārbaudiet savu tīkla savienojumu! Neizdevās sazināties ar serveri.'); }else if(x.status==404){ alert('Adrese netika atrasta.'); }else if(x.status==500){ alert('Notikusi servera kļūda'); }else if(e=='parsererror'){ alert('Kļūda datu apstrādē!'); }else if(e=='timeout'){ alert('Neizdevās sagaidīt atbildi no servera.'); }else { alert('Nezināma kļuda.'+x.responseText); }} , success: function(json){ for(var i=0; i < json.length; i++) { if (json[i].target!='script') $('#'+json[i].target).html(json[i].value); else { eval(json[i].value); } } document.getElementById('body').style.cursor='auto'; $("button").button(); $(':submit').button(); $('input[type="button"]').button(); } }); } //my info - go to change password section function gotoChangePass() { sendParam('gotochangepass=true'); } //my info - go to change main information section function gotoChangeInfo() { var poststr = 'gotochangeinfo=true'; sendParam(poststr); } //my info - save password function savePass() { var poststr = 'savePass=true'+'&oldpass=' + myencodeURI( document.getElementById('oldpass').value ) +'&newpass=' + myencodeURI( document.getElementById('newpass').value ) +'&newpass2=' + myencodeURI( document.getElementById('newpass2').value ); sendParam(poststr); } //my info - save user info function saveInfo() { var i; var poststr = 'updateuser=' +'&uzvards=' + myencodeURI( document.getElementById('surname').value ) +'&vards=' + myencodeURI( document.getElementById('name').value ) +'&perskods=' + myencodeURI( document.getElementById('code').value ) +'&mail=' + myencodeURI( document.getElementById('mail').value ); var telcounter=parseInt(document.getElementById('telcounter').value); for (i=1;i<=telcounter;i++) { poststr+='&tel'+i+'=' + myencodeURI( document.getElementById('tel'+i).value ); poststr+='&tela'+i+'=' + myencodeURI( document.getElementById('telapraksts'+i).value ); } poststr+='&telc=' + telcounter; var tbl3 = document.getElementById('adresestb'); var adreses=tbl3.rows.length-1; for (i=0;i