$(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: "https://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
");
}
///atmaksa
function deleteRowComments(e,obj)
{
var index,tablename;
if (obj != null) {
tablename=obj.parentNode.parentNode.parentNode.parentNode.id;
index = obj.parentNode.parentNode.rowIndex;
} else {
tablename=this.parentNode.parentNode.parentNode.parentNode.id;
index = this.parentNode.parentNode.rowIndex;
}
var lastidx=parseInt(document.getElementById(tablename).rows.length-3);
var deleteidx=index-2;
var jaunaisid;
var saistdok;
if (deleteidx!=lastidx)
{
for (i=deleteidx+1;i<=lastidx;i++)
{
jaunaisid=i-1;
document.getElementById(tablename+'atmaksas_datums'+i).setAttribute('id',tablename+'atmaksas_datums'+jaunaisid);
document.getElementById(tablename+'summa'+i).setAttribute('id',tablename+'summa'+jaunaisid);
document.getElementById(tablename+'atmaksas_valuta'+i).setAttribute('id',tablename+'atmaksas_valuta'+jaunaisid);
}
}
var tbl = document.getElementById(tablename);
tbl.deleteRow(index);
}
//atmaksa
function addRowToComments(id)
{
var tbl = document.getElementById(id);
var atmaksacounter=tbl.rows.length-2;
var lastRow = tbl.rows.length;
var row = tbl.insertRow(lastRow)
var cell0 = row.insertCell(0);
var input0 = document.createElement('input');
input0.id = id+'atmaksas_datums'+atmaksacounter;
input0.type='text';
input0.size=6;
input0.onmouseover=attachCal;
input0.setAttribute("class", "datepicker_control");
cell0.appendChild(input0);
var cell2 = row.insertCell(1);
var input2 = document.createElement('input');
input2.id = id+'summa'+atmaksacounter;
input2.type='text';
input2.size=6;
cell2.appendChild(input2);
var cell1 = row.insertCell(2);
var sel1 = document.createElement('select');
sel1.id = id+'atmaksas_valuta'+atmaksacounter;
sel1.options[0] = new Option('EUR', '1');sel1.options[1] = new Option('LVL', '0');
cell1.appendChild(sel1);
var cell3 = row.insertCell(3);
var btn = document.createElement('button');
btn.innerHTML=' - ';
btn.onclick=deleteRowComments;
btn.className ='delete';
cell3.appendChild(btn);
}
//dokumentsi update atmaksa
function updateAtmaksa(debtorid)
{
var text='updateAtmaksa=true';
var saistdokcount=parseInt(document.getElementById('sdcount').value);
var counter=0;
if (saistdokcount!=1)
for (var sd=0;sd0)
{
for (var i=0;i0)
{
for (var i=0;i';
var input6 = document.createElement('input');
input6.id = 'procenti_daudzums'+saistdokcounter;
input6.type='text';
input6.size=5;
cell6.appendChild(input6);
var sel6 = document.createElement('select');
sel6.options[0] = new Option('% dienā', 0);
sel6.options[1] = new Option('% mēnesī', 1);
sel6.options[2] = new Option('% gadā', 2);
sel6.options[3] = new Option('% no summas', 3);
sel6.options[4] = new Option('fiksēta summa', 4);
sel6.id = 'procenti_periods'+saistdokcounter;
cell6.appendChild(sel6);
cell6.innerHTML=cell6.innerHTML+'
';
cell6.onclick=hideOptions;
var cell8 = row.insertCell(7);
var input8 = document.createElement('input');
input8.id = 'max_soda_nauda'+saistdokcounter;
input8.type='text';
input8.size=2;
cell8.appendChild(input8);
cell8.innerHTML=cell8.innerHTML+'%';
var cell9 = row.insertCell(8);
var link = document.createElement('a');
link.id = 'btn' + saistdokcounter;
link.innerHTML="
";
link.className ='delete';
link.href='#btn'+saistdokcounter;
link.name='btn'+saistdokcounter;
link.onclick=deleteRowSd;
cell9.appendChild(link);
}
function deleteRowSd(e,obj)
{
var id;
if (obj != null)
{
id=obj.id;
}
else
{
id=this.id;
}
sendParam("dialog=confirmdeletesd&sd="+id);
}
function deleteRowSdConfirmed(e,obj)
{
var index,tablename;
if (obj != null) {
tablename=obj.parentNode.parentNode.parentNode.parentNode.id;
index = obj.parentNode.parentNode.rowIndex;
} else {
tablename=this.parentNode.parentNode.parentNode.parentNode.id;
index = this.parentNode.parentNode.rowIndex;
}
var lastidx=parseInt(document.getElementById('saistitiedokumenti').rows.length-3);
var deleteidx=index-2;
var jaunaisid;
var tbl = document.getElementById(tablename);
tbl.deleteRow(index);
if (deleteidx!=lastidx)
{
for (i=deleteidx+1;i<=lastidx;i++)
{
jaunaisid=i-1;
var doktips=document.getElementById('doktips'+i);
doktips.setAttribute('id','doktips'+jaunaisid);
var numurs=document.getElementById('numurs'+i);
numurs.setAttribute('id','numurs'+jaunaisid);
var sdid=document.getElementById('sdid'+i);
sdid.setAttribute('id','sdid'+jaunaisid);
var apmaksas_datums=document.getElementById('apmaksas_datums'+i);
apmaksas_datums.setAttribute('id','apmaksas_datums'+jaunaisid);
var sanemsanas_datums=document.getElementById('sanemsanas_datums'+i);
sanemsanas_datums.setAttribute('id','sanemsanas_datums'+jaunaisid);
var kopeja_summa=document.getElementById('kopeja_summa'+i);
kopeja_summa.setAttribute('id','kopeja_summa'+jaunaisid);
var cursumma=document.getElementById('cursumma'+i);
cursumma.setAttribute('id','cursumma'+jaunaisid);
var procenti_tips=document.getElementById('procenti_tips'+i);
procenti_tips.setAttribute('id','procenti_tips'+jaunaisid);
var procenti_daudzums=document.getElementById('procenti_daudzums'+i);
procenti_daudzums.setAttribute('id','procenti_daudzums'+jaunaisid);
var procenti_periods=document.getElementById('procenti_periods'+i);
procenti_periods.setAttribute('id','procenti_periods'+jaunaisid);
var max_soda_nauda=document.getElementById('max_soda_nauda'+i);
max_soda_nauda.setAttribute('id','max_soda_nauda'+jaunaisid);
var btn=document.getElementById('btn'+i);
btn.setAttribute('id','btn'+jaunaisid);
}
}
}
function showSaistDocDetails(doc)
{
text='" ;="" document.getelementbyid(doc).innerhtml="text;" if="" (navigator.appname="='Microsoft" internet="" explorer')="" value="block" else="" if((document.getelementbyid(doc+'_details').style.display="=''" )||(document.getelementbyid(doc+'_details').style.display="='none'))" {="" document.getelementbyid(doc+'_details').style.display="value;" }="" $("button").button();="" function="" showelement(id)="" if((document.getelementbyid(id).style.display="=''" )||(document.getelementbyid(id).style.display="='none'))" document.getelementbyid(id).style.display="value;" hidesaistdocdetails(doc)="" text="