function normal_ls( v ){ v = String( v ); v = v.replace( ',', '.' ); var pp = v.length - v.indexOf( '.' ); if( v.indexOf( '.' ) == -1 ){ v += '.00'; return v; } if( pp > 2 && v.indexOf( '.' ) != -1 ) v = v.substr( 0, v.length - ( pp - 3 ) ); if( pp == 2 ) v += '0'; if( pp == 1 ) v += '00'; return v; } function piev_grozs( id ){ RPC.send( 'piev_grozs', new i( { 'prece_id':id } ), re_piev_grozs, '' ); el( 'grozs' ).innerHTML = ''; mountLoad( el( 'grozs' ) ); } function re_piev_grozs( re, par ){ echo_grozs( re, par ); } function echo_grozs_login( re, par ){ var e = el( 'grozs' ); if( re.v( 'user_id' ) != 0 ){ e.appendChild( mkE( { 'tag':'div', 'prop':{ 'id':'login' }, 'els':[ mkE( { 'tag':'div', 'text':'Ielogojies:', 'prop':{ 'className':'xcol_capt' } } ), mkE( { 'tag':'div', 'prop':{ 'className':'xcol_row' }, 'els':[ mkE( { 'tag':'div', 'text':re.v( 'user_name' ), 'prop':{ 'className':'grozs_user_name' } } ), mkE( { 'tag':'div', 'els': mkE( { 'tag':'img', 'prop':{ 'src':'/preces_/logout.png', 'title':'Iziet', 'style':{ 'cursor':'hand', 'cursor':'pointer' }, 'onclick':grozs_logout } } ), 'prop':{ 'className':'grozs_logout' } } ) ] } ) ] } ) ); } } function echo_grozs( re, par ){ if( document.location.href.indexOf( 'precu_grozs.php#reload' ) != -1 ) document.location.href = 'precu_grozs.php'; el( 'grozs' ).innerHTML = ''; var e = el( 'grozs' ); echo_grozs_login( re, par ); e.appendChild( e = mkE( { 'tag':'div', 'prop':{ 'id':'groza_saturs' } } ) ); e.appendChild( mkE( { 'tag':'div', 'prop':{ 'className':'xcol_capt' }, 'text':'Grozs' } ) ); var row = null; var first = false; while( row = re.v( 'preces' ).next() ){ if( ! first ){ e.appendChild( mkE( { 'tag':'div', 'prop':{ 'id':'kopsumma' }, 'els':[ mkE( { 'tag':'div', 'text':'Kopsumma:', 'prop':{ 'id':'grozs_kopsum_capt' } } ), mkE( { 'tag':'div', 'text':normal_ls( re.v( 'ks' ) ) + ' ' + currency_name, 'prop':{ 'id':'grozs_kopsum_val' } } ) ] } ) ); } first = true; e.appendChild( mkE( { 'tag':'div', 'prop':{ 'className':'gorzs_prece' }, 'els':[ mkE( { 'tag':'a', /*'a'*/ 'prop':{ 'href':row.v( 'link' ) }, 'els':[ mkE( { 'tag':'div', 'prop':{ 'className':'grozs_prece_nosauk' }, 'text':row.v( 'prece' ).v( 'nosauk' ) } ) ] } ), mkE( { 'tag':'div', 'text':'Skaits: ' + row.v( 'sk' ), 'prop':{ 'style':{ 'display':( row.v( 'sk' ) == 1 ? 'none' : '' ) } } } ), mkE( { 'tag':'div', 'text':'Cena: ' + normal_ls( row.v( 'prece' ).v( 'web_sum' ) ) + ' ' + currency_name } ), mkE( { 'tag':'div', 'text':'Summa: ' + normal_ls( row.v( 'kop_sum' ) ) + ' ' + currency_name, 'prop':{ 'style':{ 'display':( row.v( 'sk' ) == 1 ? 'none' : '' ) } } } ), mkE( { 'tag':'div', 'text':'[izmest]', 'prop':{ 'prece_id':row.v( 'id' ), 'onclick':izmest_grozs, 'style':{ 'cursor':'hand', 'cursor':'pointer' } } } ) ] } ) ); } if( first ){ e.appendChild( mkE( { 'tag':'button', 'text':'Pirkt', 'prop':{ 'onclick':pirkt } } ) ); } else { e.appendChild( mkE( { 'tag':'div', 'text':'Grozā preču nav' } ) ); } } function grozs_logout(){ RPC.send( 'logout', '', re_grozs_logout, '' ); } function re_grozs_logout( re, par ){ echo_grozs( re, par ); } function izmest_grozs(){ if( document.location.href.indexOf( 'precu_grozs.php' ) != -1 ) document.location.href = '#reload'; RPC.send( 'izmest_grozs', new i( { 'prece_id':this.prece_id } ), re_izmest_grozs, '' ); el( 'grozs' ).innerHTML = ''; mountLoad( el( 'grozs' ) ); } function re_izmest_grozs( re, par ){ echo_grozs( re, par ); } function pirkt(){ document.location.href = '/preces/precu_grozs.php'; //RPC.send( 'pirkt', '', re_pirkt, this ); } function re_pirkt( re, par ){ rmEl( par ); var e = el( 'grozs' ); if( re.v( 'user_id' ) == 0 ){ e.appendChild( mkE( { 'tag':'div', 'prop':{ 'id':'atr_pas_id' }, 'els':[ mkE( { 'tag':'div', 'prop':{ 'className':'grozs_xcol_capt' }, 'text':'Ātrais pasūtījums' } ), mkE( { 'tag':'div', 'prop':{ 'className':'xcol_row2' }, 'els':[ mkE( { 'tag':'div', 'text':'Vārds:' } ), e.atr_name = mkE( { 'tag':'input', 'prop':{ 'type':'text', 'className':'input_text' } } ) ] } ), mkE( { 'tag':'div', 'prop':{ 'className':'xcol_row2' }, 'els':[ mkE( { 'tag':'div', 'text':'Telefons:' } ), e.atr_phone = mkE( { 'tag':'input', 'prop':{ 'type':'text', 'className':'input_text' } } ) ] } ), mkE( { 'tag':'button', 'text':'Pirkt', 'prop':{ 'onclick':atr_pas } } ), mkE( { 'tag':'button', 'text':'Pirkt Swedbank', 'prop':{ 'onclick':atr_pas, 'hansanet':true } } ) ] } ) ); e.appendChild( mkE( { 'tag':'div', 'prop':{ 'id':'login_id' }, 'els':[ mkE( { 'tag':'div', 'prop':{ 'className':'grozs_xcol_capt' }, 'text':'Reģistrētiem klientiem' } ), mkE( { 'tag':'div', 'els':[ mkE( { 'tag':'div', 'prop':{ 'className':'xcol_row2' }, 'text':'E-pasts:' } ), e.email = mkE( { 'tag':'input', 'prop':{ 'type':'text', 'name':'email', 'className':'input_text' } } ) ] } ), mkE( { 'tag':'div', 'els':[ mkE( { 'tag':'div', 'text':'Parole:' } ), e.psw = mkE( { 'tag':'input', 'prop':{ 'type':'password', 'className':'input_text', 'onkeyup':enter, 'onEnter':login } } ) ] } ), mkE( { 'tag':'button', 'text':'Ielogoties', 'prop':{ 'onclick':login } } ), mkE( { 'tag':'div', 'els':[ mkE( { 'tag':'a', 'text':'Reģistrēties', 'prop':{ 'href':'#reg', 'title':'Reģistrēties', 'onclick':reg } } ) ] } ) ] } ) ); } else { var apm, button; e.appendChild( mkE( { 'tag':'div', 'els':[ mkE( { 'tag':'div', 'text':'Apmaksas veids:' } ), apm = mkE( { 'tag':'select', 'els':[ mkE( { 'tag':'option', 'text':'Ar pārskaitījumu', 'prop':{ 'value':'0' } } ), mkE( { 'tag':'option', 'text':'HansaNet', 'prop':{ 'value':'1' } } ) ] } ), mkE( { 'tag':'div', 'text':'Komentārs' } ), mkE( { 'tag':'div', 'els':[ e.com = mkE( { 'tag':'textarea', 'prop':{ 'className':'input_text' } } ) ] } ), mkE( { 'tag':'div', 'els': button = mkE( { 'tag':'button', 'text':'Pirkt', 'prop':{ 'onclick':pirkt_login } } ) } ) ] } ) ); button.apm = apm; } } function pirkt_login(){ el( 'grozs' ).apm = { 'value':this.apm.value }; RPC.send( 'pirkt_login', new i( { 'com':el( 'grozs' ).com.value } ), re_pirkt_login, el( 'grozs' ) ); } function re_pirkt_login( re, par ){ par.innerHTML = ''; echo_grozs_login( re, par ); par.appendChild( mkE( { 'tag':'span', 'text':dic[ 'paldies' ][ current_lang ] } ) ); if( par.apm.value == 1 ){ document.location.href = '/preces/hansanet.php'; } } function atr_pas(){ var e = el( 'grozs' ); if( e.atr_name.value.length < 3 ){ alert( dic[ 'no_name' ][ current_lang ] ); return false; } if( e.atr_phone.value.length < 7 ){ alert( dic[ 'no_phone' ][ current_lang ] ); return false; } if( this.hansanet ) e.hansanet = true; RPC.send( 'atr_pas', new i( { 'name':e.atr_name.value, 'phone':e.atr_phone.value } ), re_atr_pas, e ); e.innerHTML = ''; } function re_atr_pas( re, par ){ par.innerHTML = 'Paldies'; if( par.hansanet ) document.location.href = '/preces/hansanet.php'; } function login(){ var e = el( 'grozs' ); RPC.send( 'login', new i( { 'email':e.email.value, 'psw':e.psw.value } ), re_login, '' ); } function re_login( re, par ){ var e = el( 'grozs' ); if( re == 0 ){ alert( 'Nepareizs lietotāja vārds vai parole' ); e.psw.value = ''; return; } RPC.send( 'get_grozs', '', re_re_login, '' ); } function re_re_login( re, par ){ echo_grozs( re, par ); } function reg(){ var e = el( 'login_id' ); e.innerHTML = ''; e.appendChild( mkE( { 'tag':'div', 'prop':{ 'className':'grozs_xcol_capt' }, 'text':dic[ 'reg2' ][ current_lang ] } ) ); e.appendChild( mkE( { 'tag':'div', 'els':[ mkE( { 'tag':'div', 'text':'Klients:' } ), mkE( { 'tag':'div', 'els':[ e.c_type = mkE( { 'tag':'select', 'prop':{ 'onchange':change_reg_anketa }, 'els':[ mkE( { 'tag':'option', 'text':'Privātpersona', 'prop':{ 'value':0 } } ), mkE( { 'tag':'option', 'text':'Juridiska persona', 'prop':{ 'value':1 } } ) ] } ) ] } ) ] } ) ); var priv = {}; e.appendChild( e.priv_anketa = mkE( { 'tag':'div', 'els':[ mkE( { 'tag':'div', 'els':[ mkE( { 'tag':'div', 'text':'E-pasts:' } ), mkE( { 'tag':'div', 'els': priv.email = mkE( { 'tag':'input', 'prop':{ 'type':'text', 'name':'email', 'className':'input_text' } } ) } ) ] } ), mkE( { 'tag':'div', 'els':[ mkE( { 'tag':'div', 'text':'Vārds, uzvārds:' } ), mkE( { 'tag':'div', 'els': priv.name = mkE( { 'tag':'input', 'prop':{ 'type':'text', 'className':'input_text' } } ) } ) ] } ), mkE( { 'tag':'div', 'els':[ mkE( { 'tag':'div', 'text':'Telefons:' } ), mkE( { 'tag':'div', 'els': priv.phone = mkE( { 'tag':'input', 'prop':{ 'type':'text', 'className':'input_text' } } ) } ) ] } ), mkE( { 'tag':'div', 'els':[ mkE( { 'tag':'div', 'text':'Personas kods:' } ), mkE( { 'tag':'div', 'els': priv.code = mkE( { 'tag':'input', 'prop':{ 'type':'text', 'className':'input_text' } } ) } ) ] } ), mkE( { 'tag':'div', 'els':[ mkE( { 'tag':'div', 'text':'Parole:' } ), mkE( { 'tag':'div', 'els': priv.psw1 = mkE( { 'tag':'input', 'prop':{ 'type':'password', 'maxLength':15, 'className':'input_text' } } ) } ) ] } ), mkE( { 'tag':'div', 'els':[ mkE( { 'tag':'div', 'text':'Parole atkārtoti:' } ), mkE( { 'tag':'div', 'els': priv.psw2 = mkE( { 'tag':'input', 'prop':{ 'type':'password', 'maxLength':15, 'className':'input_text' } } ) } ) ] } ), mkE( { 'tag':'div', 'els': e.priv_but = mkE( { 'tag':'button', 'text':'Reģistrēties', 'prop':{ 'onclick':priv_reg } } ) } ) ] } ) ); e.priv_but.e = priv; var jur = {}; e.appendChild( e.jur_anketa = mkE( { 'tag':'div', 'prop':{ 'style':{ 'display':'none' } }, 'els':[ mkE( { 'tag':'div', 'els':[ mkE( { 'tag':'div', 'text':'E-pasts' } ), mkE( { 'tag':'div', 'els': jur.email = mkE( { 'tag':'input', 'prop':{ 'type':'text', 'name':'email', 'className':'input_text' } } ) } ) ] } ), mkE( { 'tag':'div', 'els':[ mkE( { 'tag':'div', 'text':'Nosaukums:' } ), mkE( { 'tag':'div', 'els': jur.name = mkE( { 'tag':'input', 'prop':{ 'type':'text', 'className':'input_text' } } ) } ) ] } ), mkE( { 'tag':'div', 'els':[ mkE( { 'tag':'div', 'text':'Telefons:' } ), mkE( { 'tag':'div', 'els': jur.phone = mkE( { 'tag':'input', 'prop':{ 'type':'text', 'className':'input_text' } } ) } ) ] } ), mkE( { 'tag':'div', 'els':[ mkE( { 'tag':'div', 'text':'Fakss:' } ), mkE( { 'tag':'div', 'els': jur.fax = mkE( { 'tag':'input', 'prop':{ 'type':'text', 'className':'input_text' } } ) } ) ] } ), mkE( { 'tag':'div', 'els':[ mkE( { 'tag':'div', 'text':'Reģistrācijas nr.:' } ), mkE( { 'tag':'div', 'els': jur.code = mkE( { 'tag':'input', 'prop':{ 'type':'text', 'className':'input_text' } } ) } ) ] } ), mkE( { 'tag':'div', 'els':[ mkE( { 'tag':'div', 'text':'Banka:' } ), mkE( { 'tag':'div', 'els': jur.banka = mkE( { 'tag':'input', 'prop':{ 'type':'text', 'className':'input_text' } } ) } ) ] } ), mkE( { 'tag':'div', 'els':[ mkE( { 'tag':'div', 'text':'Bankas kods' } ), mkE( { 'tag':'div', 'els': jur.banka_kods = mkE( { 'tag':'input', 'prop':{ 'type':'text', 'className':'input_text' } } ) } ) ] } ), mkE( { 'tag':'div', 'els':[ mkE( { 'tag':'div', 'text':'Konts' } ), mkE( { 'tag':'div', 'els': jur.konts = mkE( { 'tag':'input', 'prop':{ 'type':'text', 'className':'input_text' } } ) } ) ] } ), mkE( { 'tag':'div', 'els':[ mkE( { 'tag':'div', 'text':'Parole' } ), mkE( { 'tag':'div', 'els': jur.psw1 = mkE( { 'tag':'input', 'prop':{ 'type':'password', 'maxLength':15, 'className':'input_text' } } ) } ) ] } ), mkE( { 'tag':'div', 'els':[ mkE( { 'tag':'div', 'text':'Parole atkārtoti' } ), mkE( { 'tag':'div', 'els': jur.psw2 = mkE( { 'tag':'input', 'prop':{ 'type':'password', 'maxLength':15, 'className':'input_text' } } ) } ) ] } ), mkE( { 'tag':'div', 'els': e.jur_but = mkE( { 'tag':'button', 'text':'Reģistrēties', 'prop':{ 'onclick':jur_reg } } ) } ) ] } ) ); e.jur_but.e = jur; } function change_reg_anketa(){ var e = el( 'login_id' ); if( this.value == 0 ){ e.priv_anketa.style.display = ''; e.jur_anketa.style.display = 'none'; } else { e.priv_anketa.style.display = 'none'; e.jur_anketa.style.display = ''; } } function priv_reg(){ var em = /^[^\s]+@[^\s]+\.[^\s]+$/; var pk = /^\d{6}-{0,1}\d+$/; var phone = /^\+{0,1}[\d\s]{7,}$/; var color = null; if( ! this.e.email.value.match( em ) ){ color = this.e.email.style.backgroundColor; this.e.email.style.backgroundColor = '#f00'; alert( 'E-pasts ir nepareizs!' ); this.e.email.style.backgroundColor = color; return false; } if( this.e.name.value.length < 3 ){ color = this.e.name.style.backgroundColor; this.e.name.style.backgroundColor = '#f00'; alert( 'Aizpildiet lauku!' ); this.e.name.style.backgroundColor = color; return false; } if( ! this.e.phone.value.match( phone ) ){ color = this.e.phone.style.backgroundColor; this.e.phone.style.backgroundColor = '#f00'; alert( 'Aizpildiet lauku!' ); this.e.phone.style.backgroundColor = color; return false; } if( ! this.e.code.value.match( pk ) ){ color = this.e.code.style.backgroundColor; this.e.code.style.backgroundColor = '#f00'; alert( 'Aizpildiet lauku!' ); this.e.code.style.backgroundColor = color; return false; } if( this.e.psw1.value.length < 4 ){ color = this.e.psw1.style.backgroundColor; this.e.psw1.style.backgroundColor = '#f00'; alert( 'Parole ir par īsu, jābūt vismaz 4 simboliem!' ); this.e.psw1.style.backgroundColor = color; this.e.psw1.value = ''; this.e.psw2.value = ''; return false; } if( this.e.psw1.value != this.e.psw2.value ){ color = this.e.psw1.style.backgroundColor; this.e.psw1.style.backgroundColor = '#f00'; this.e.psw2.style.backgroundColor = '#f00'; alert( 'Paroles ir dažādas!' ); this.e.psw1.style.backgroundColor = color; this.e.psw2.style.backgroundColor = color; this.e.psw1.value = ''; this.e.psw2.value = ''; return false; } var ee = this.e; RPC.send( 'priv_reg', new i( { 'email':ee.email.value, 'name':ee.name.value, 'phone':ee.phone.value, 'code':ee.code.value, 'psw':ee.psw1.value } ), re_reg, '' ); el( 'login_id' ).innerHTML = ''; } function re_reg( re, par ){ echo_grozs( re, par ); } function jur_reg(){ var em = /^[^\s]+@[^\s]+\.[^\s]+$/; var phone = /^\+{0,1}[\d\s]{7,}$/; var konts = /^[a-zA-Z]{2}\d{2}[a-zA-Z]{4}[a-zA-Z0-9]{13}$/; var color = null; if( ! this.e.email.value.match( em ) ){ color = this.e.email.style.backgroundColor; this.e.email.style.backgroundColor = '#f00'; alert( 'E-pasts ir nepareizs!' ); this.e.email.style.backgroundColor = color; return false; } if( this.e.name.value.length < 3 ){ color = this.e.name.style.backgroundColor; this.e.name.style.backgroundColor = '#f00'; alert( 'Aizpildiet lauku!' ); this.e.name.style.backgroundColor = color; return false; } if( ! this.e.phone.value.match( phone ) ){ color = this.e.phone.style.backgroundColor; this.e.phone.style.backgroundColor = '#f00'; alert( 'Aizpildiet lauku!' ); this.e.phone.style.backgroundColor = color; return false; } if( this.e.code.value.length < 5 ){ color = this.e.code.style.backgroundColor; this.e.code.style.backgroundColor = '#f00'; alert( 'Aizpildiet lauku!' ); this.e.code.style.backgroundColor = color; return false; } if( this.e.banka.value.length < 3 ){ color = this.e.banka.style.backgroundColor; this.e.banka.style.backgroundColor = '#f00'; alert( 'Aizpildiet lauku!' ); this.e.banka.style.backgroundColor = color; return false; } if( this.e.banka_kods.value.length == '' ){ color = this.e.banka_kods.style.backgroundColor; this.e.banka_kods.style.backgroundColor = '#f00'; alert( 'Aizpildiet lauku!' ); this.e.banka_kods.style.backgroundColor = color; return false; } if( ! this.e.konts.value.match( konts ) ){ color = this.e.konts.style.backgroundColor; this.e.konts.style.backgroundColor = '#f00'; alert( 'Aizpildiet lauku!' ); this.e.konts.style.backgroundColor = color; return false; } if( this.e.psw1.value.length < 4 ){ color = this.e.psw1.style.backgroundColor; this.e.psw1.style.backgroundColor = '#f00'; alert( 'Parole ir par īsu, jābūt vismaz 4 simboliem!' ); this.e.psw1.style.backgroundColor = color; this.e.psw1.value = ''; this.e.psw2.value = ''; return false; } if( this.e.psw1.value != this.e.psw2.value ){ color = this.e.psw1.style.backgroundColor; this.e.psw1.style.backgroundColor = '#f00'; this.e.psw2.style.backgroundColor = '#f00'; alert( 'Paroles ir dažādas!' ); this.e.psw1.style.backgroundColor = color; this.e.psw2.style.backgroundColor = color; this.e.psw1.value = ''; this.e.psw2.value = ''; return false; } var ee = this.e; RPC.send( 'jur_reg', new i( { 'email':ee.email.value, 'name':ee.name.value, 'phone':ee.phone.value, 'fax':ee.fax.value, 'code':ee.code.value, 'banka':ee.banka.value, 'banka_kods':ee.banka_kods.value, 'konts':ee.konts.value, 'psw':ee.psw1.value } ), re_reg, '' ); el( 'login_id' ).innerHTML = ''; } // -------------------------------- WIN MAIL ----------------------------------- var win_mail = mkW( { 'caption':'E-pasts', 'height':210, 'width':200, 'left':400, 'top':200 } ); function win_mail_append( id, capt ){ win_mail.Append( el( 'deskatop' ) ); win_mail.Caption.innerHTML = 'Sūtīt e-pastā - ' + id; clearNode( win_mail.Body ); win_mail.Body.appendChild( mkE( { 'tag':'div', 'text':capt, 'prop':{ 'style':{ 'width':'100%', 'height':'45px', 'textAlign':'left', 'paddingLeft':'3px' } } } ) ); win_mail.Body.appendChild( mkE( { 'tag':'div', 'text':'E-pasts:', 'prop':{ 'style':{ 'position':'absolute', 'top':'45px', 'left':'15px' } }, 'els': win_mail.email = mkE( { 'tag':'input', 'prop':{ 'type':'text', 'className':'input_text', 'style':{ 'position':'absolute', 'left':'0px', 'top':'15px', 'width':'170px' } } } ) } ) ); win_mail.Body.appendChild( mkE( { 'tag':'div', 'text':'Komentāri:', 'prop':{ 'style':{ 'position':'absolute', 'top':'80px', 'left':'15px' } }, 'els': win_mail.com = mkE( { 'tag':'textarea', 'prop':{ 'className':'input_text', 'style':{ 'position':'absolute', 'left':'0px', 'top':'15px', 'width':'170px' } } } ) } ) ); win_mail.Body.appendChild( mkE( { 'tag':'button', 'text':'Sūtīt', 'prop':{ 'onclick':win_mail_send, 'prece_id':Number( id ), 'style':{ 'position':'absolute', 'top':'150px', 'left':'140px', 'width':'50px' } } } ) ); win_mail.Body.style.backgroundColor = '#ddd'; } function win_mail_send(){ RPC.send( 'win_mail_send', new i( { 'prece_id':this.prece_id, 'email':win_mail.email.value, 'com':win_mail.com.value } ), re_win_mail_send, '' ); win_mail.Close(); } function re_win_mail_send( re, par ){ } // ================================ WIN MAIL ===================================