'
-
- if zag > 0:
- #desc = cur.description
- shtml = shtml + ''
- for polje in zagl:
- shtml = shtml + ''
- shtml = shtml + '' + polje + ' '
- shtml = shtml + ' '
- shtml = shtml + ' '
-
- #table body
- rows = cur.fetchall()
-
- nisti = 1
- svod = '??'
- tred = ''
- for red in rows:
- idx = 0
- for polje in red:
- if type(polje) is int:
- spolje = str(polje)
- else:
- polje = polje.encode('utf8')
- spolje = str(polje)
-
- if idx == 0:
- # prvo poje (vodotok)
- if spolje != svod:
- # novi vodotok
- if tred != '':
- # zapisemo do sada formirame redove
- if nisti > 1:
- nisti = nisti + 1
- tred = tred.replace('', '')
- tred = tred.replace('', '')
- tred = tred.replace(' ', '')
- tred = ' ' + tred + ' '
- shtml = shtml + tred
- tred = ''
- nisti = 1
- tred = tred + ''
- if str(polje) == 'None':
- tred = tred + ' '
- else:
- tred = tred + '' + spolje + ' '
- tred = tred + ' '
- svod = spolje
- else:
- nisti = nisti + 1
- tred = tred + ''
- else:
- tred = tred + ''
- if str(polje) == 'None':
- tred = tred + ' '
- else:
- if idx == 2:
- if spolje == '1':
- spolje = ' '
- elif spolje == '-1':
- spolje = ' '
- else:
- spolje = ' '
- tred = tred + spolje
- tred = tred + ' '
-
- idx = idx + 1
- tred = tred + ' '
-
- if nisti > 1:
- nisti = nisti + 1
- tred = tred.replace('', '')
- tred = tred.replace('', '')
- tred = tred.replace(' ', '')
- tred = ' ' + tred + ' '
- shtml = shtml + tred
- return shtml
-
-
-#================================
-def Tabela2html(cur, zag, align):
- shtml = ''
- #table header
- shtml = shtml + ''
-
- rcl = 0
- if zag > 0:
- desc = cur.description
- shtml = shtml + ''
- for polje in desc:
- shtml = shtml + ''
- shtml = shtml + '' + polje[0] + ' '
- shtml = shtml + ' '
- shtml = shtml + ' '
- rcl = 1
-
- #table body
- rows = cur.fetchall()
-
- for red in rows:
- shtml = shtml + ''
-
- idx = 0
- for polje in red:
- polje = polje.encode('utf8')
- if rcl == 1:
- shtml = shtml + ''
- else:
- shtml = shtml + ' '
-
- if str(polje) == 'None':
- shtml = shtml + ' '
- else:
- spolje = str(polje)
- if spolje.find('m3/s') != -1:
- spolje = spolje.replace('m3/s', 'm3 /s')
- shtml = shtml + spolje
-
- shtml = shtml + ' '
- idx = idx + 1
-
- shtml = shtml + ' '
- rcl = rcl + 1
- if rcl > 1:
- rcl = 0
-
- shtml = shtml + '
'
- return shtml
-
-
-#===================
-def Zapis2html(cur):
- shtml = ''
- #table header
- shtml = shtml + ''
- try:
- #table body
- rows = cur.fetchall()
- desc = cur.description
- if len(rows) > 0:
- rcl = 0
- idx = 0
- for polje in desc:
- shtml = shtml + ''
-
- if rcl == 1:
- shtml = shtml + ''
- else:
- shtml = shtml + ' '
- if str(polje) == 'None':
- shtml = shtml + ' '
- else:
- imep = polje[0]
- if imep.find('Topografska') != -1:
- imep = 'Topografska površina sliva (km2 )'
- shtml = shtml + imep
- shtml = shtml + ' '
-
- if rcl == 1:
- shtml = shtml + ''
- else:
- shtml = shtml + ' '
- if rows[0][idx]:
- if type(rows[0][idx]) is datetime.date:
- shtml = shtml + "%02d. %02d. %04d." % (rows[0][idx].day, rows[0][idx].month, rows[0][idx].year)
- elif type(rows[0][idx]) is float:
- spod = "%.3f" % rows[0][idx]
- spod = spod.replace('.', ',')
- shtml = shtml + spod
- elif type(rows[0][idx]) is int:
- shtml = shtml + str(rows[0][idx])
- else:
- shtml = shtml + rows[0][idx].encode('utf8')
- else:
- shtml = shtml + ' --'
-
- shtml = shtml + ' '
-
- shtml = shtml + ' '
- rcl = rcl + 1
- if rcl > 1:
- rcl = 0
- idx = idx + 1
- except:
- pass
-
- shtml = shtml + '
'
- return shtml
-
-
-#====================
-def mjerenjaPostaje():
- post = ''
- cur = izvrsisql("select IME, IME_VODOTOKA from POSTAJE_SVE where KOD = " + form.getvalue('kpost'))
- try:
- if cur:
- rows = cur.fetchall()
- if len(rows) > 0:
- post = rows[0][0].encode('utf8') + ', ' + rows[0][1].encode('utf8')
- except:
- post = '??'
-
- try:
- print ''
- print '
'
- print 'Mjerenja postaje: ' + post + ' '
- print ' '
- print ''
-
- cur = izvrsisql('select VRSTA_MJERENJA as "Vrsta mjerenja",'
- ' (select * FROM PROC_GODINE_MJERENJA(KOD_POSTAJE,TIP_MJERENJA)) as "Godine/broj mjerenja"'
- ' from MJERENJA where KOD_POSTAJE = ' + form.getvalue('kpost') + " order by RBR_TIPA")
- if cur:
- print Tabela2html(cur, 1, ['right', 'left'])
- cur.close()
- else:
- print 'g1'
- except:
- divGreska()
-
-
-#=================
-def infoPostaje():
- try:
- print ''
- print '
'
- print 'Osnovni podaci postaje'
- print ' '
- print ''
-
- if form.getvalue('kpost') > 0:
- cur = izvrsisql('select IME as "Ime", SIFRA as "Šifra", IME_VODOTOKA as "Vodotok", '
- 'IME_SLIVA as "Slivno područje", POCETAK_RADA as "Početak rada", KRAJ_RADA as "Kraj rada",'
- ' KOTA_NULE as "Kota nule vodokaza (m n/m)" from POSTAJE_SVE where KOD = ' +
- form.getvalue('kpost'))
- if cur:
- print Zapis2html(cur)
- cur.close()
- else:
- divGreska()
- except:
- divGreska()
-
-
-#=========================
-def infoMjerenjaPostaje():
- try:
- print ''
- print '
'
- print 'Mjerenja postaje'
- print ' '
- print ''
-
- cur = izvrsisql('select MJERENJE as "Vrsta mjerenja", INFO as "Info" from TINFO_MJERENJA_POSTAJE(' +
- form.getvalue('kpost') + ')')
- if cur:
- print Tabela2html(cur, 1, ['right', 'left'])
- cur.close()
- else:
- divGreska()
-
- except:
- divGreska()
-
-
-#============
-def Bilten():
- try:
- tip = 1
- if 'btip' in form:
- tip = int(form.getvalue('btip'))
- except:
- tip = 1
-
- tip = 1
- try:
- if 'zadpod' in form:
- term = datetime.datetime.utcnow() + datetime.timedelta(0, 3600)
- if term.hour < 7:
- term = term - datetime.timedelta(days=1)
- strm = str(term.year) + '-' + str(term.month) + '-' + str(term.day) + ' ' + str(term.hour) + ':00:00'
- sstrm = str(term.day) + '. ' + str(term.month) + '. ' + str(term.year) + '. ' + str(term.hour) + ':00:00'
- else:
- term = datetime.datetime.utcnow() + datetime.timedelta(0, 3600)
- if term.hour < 8:
- term = term - datetime.timedelta(days=1)
- strm = str(term.year) + '-' + str(term.month) + '-' + str(term.day) + ' 07:00:00'
- sstrm = str(term.day) + '. ' + str(term.month) + '. ' + str(term.year) + '. 07:00:00'
-
- cur = izvrsisql("select VODOTOK,POSTAJA,TREND,VODOSTAJ,TENDENCIJA,PROTOK from WEB_BILTEN('" + strm + "', " + str(tip) + ")")
- if cur:
- print TabelaBilten(cur, 1, ['center', 'left', 'center', 'center', 'center', 'center'], sstrm)
- cur.close()
- else:
- print 'cur greska'
- #divGreska()
-
- except Exception, e:
- print 'GRESKA ' + str(e)
- #divGreska()
-
-
-#=============
-def BiltenX():
- try:
- tip = 1
- if 'btip' in form:
- tip = int(form.getvalue('btip'))
- except:
- tip = 1
-
- try:
- if 'zadpod' in form:
- term = datetime.datetime.utcnow() + datetime.timedelta(0, 3600)
- if term.hour < 7:
- term = term - datetime.timedelta(days=1)
- strm = str(term.year) + '-' + str(term.month) + '-' + str(term.day) + ' ' + str(term.hour) + ':00:00'
- sstrm = str(term.day) + '. ' + str(term.month) + '. ' + str(term.year) + '. ' + str(term.hour) + ':00:00'
- else:
- term = datetime.datetime.utcnow() + datetime.timedelta(0, 3600)
- if term.hour < 8:
- term = term - datetime.timedelta(days=1)
- strm = str(term.year) + '-' + str(term.month) + '-' + str(term.day) + ' 07:00:00'
- sstrm = str(term.day) + '. ' + str(term.month) + '. ' + str(term.year) + '. 07:00:00'
-
- cur = izvrsisql("select VODOTOK,POSTAJA,TREND,VODOSTAJ,TENDENCIJA,PROTOK from WEB_BILTEN_X('" + strm + "', " + str(tip) + ")")
- if cur:
- print TabelaBilten(cur, 1, ['center', 'left', 'center', 'center', 'center', 'center'], sstrm)
- cur.close()
- else:
- print 'cur greska'
- #divGreska()
-
- except Exception, e:
- print 'GRESKA ' + str(e)
- #divGreska()
-
-
-#=================
-def punInfoPostaje():
- sirprof = 40
- if ('sirina' in form) and ('visina' in form):
- try:
- sirprof = int(form.getvalue('sirina'))
- visprof = int(form.getvalue('visina')) + 220
- sirprof = (sirprof * 100) / visprof
- except:
- sirprof = 40
-
- post = '??'
- koment = 'None'
- cur = izvrsisql("select SIFRA, KOMENTAR from POSTAJE where KOD = " + form.getvalue('kpost'))
- try:
- if cur:
- rows = cur.fetchall()
- if len(rows) > 0:
- post = str(rows[0][0])
- try:
- koment = rows[0][1].encode('utf8')
- except:
- koment = 'None'
- except:
- post = '??'
-
- try:
- # slika
- if post != '??':
- lpath = os.getcwd()
- sifpost = post
-
- lpost = lpath[0:lpath.rfind('/')] + '/slike/' + sifpost + '.jpg'
- post = '../slike/' + sifpost + '.jpg'
- if os.path.isfile(lpost):
- print ''
- print '
'
- print '
'
- if koment != 'None':
- print '•••'
- print '
'
-
- if koment != 'None':
- print ''
- #print ' '
- print koment
- print '
'
-
- print ''
- print '
'
- print 'Osnovni podaci postaje'
- print ' '
- print ''
-
- if form.getvalue('kpost') > 0:
- cur = izvrsisql('select * FROM INFO_POSTAJE(' + form.getvalue('kpost') + ')')
- if cur:
- print Zapis2html(cur)
- cur.close()
- else:
- divGreska()
-
- infoMjerenjaPostaje()
-
- lpost = lpath[0:lpath.rfind('/')] + '/slike/' + sifpost + '.svg'
- post = '../slike/' + sifpost + '.svg'
- if os.path.isfile(lpost):
- #print ''
- print '
'
- print 'SVG nije podržan! '
- #print ''
- #print ''
-
- print ''
- print '
'
- print ''
- except:
- divGreska()
-
-
-#===================
-def profilPostaje():
- post = '??'
- cur = izvrsisql("select SIFRA from POSTAJE where KOD = " + form.getvalue('kpost'))
- try:
- if cur:
- rows = cur.fetchall()
- if len(rows) > 0:
- post = str(rows[0][0])
- except:
- post = '??'
-
- try:
- # slika
- if post != '??':
- lpath = os.getcwd()
- sifpost = post
- lpost = lpath[0:lpath.rfind('/')] + '/slike/' + sifpost + '.svg'
- post = '../slike/' + sifpost + '.svg'
- if os.path.isfile(lpost):
- #print ''
- if 'fullsize' in form:
- print 'SVG nije podržan! '
- else:
- print 'SVG nije podržan! '
- #print ''
- #print '
'
- else:
- print ''
- print 'Nema profila postaje.'
- print '
'
- else:
- divGreska()
- except:
- divGreska()
-
-
-#=================
-def slivVodInfo():
- try:
- print ''
- cur = izvrsisql('select IME as "Slivno područje", BROJ_VODOTOKOVA as "Broj vodotokova", '
- 'BROJ_POSTAJA as "Broj postaja" from SLIVNA_PODRUCJA where KOD=' + form.getvalue('ksliv'))
- if cur:
- print Zapis2html(cur)
- cur.close()
- else:
- pass
- print '
'
- print ''
- cur = izvrsisql('select IME as "Vodotok", BROJ_POSTAJA as "Broj postaja" from VODOTOCI where KOD=' +
- form.getvalue('kvod'))
- if cur:
- print Zapis2html(cur)
- cur.close()
- else:
- pass
- print '
'
- except:
- pass
-
-
-#==============
-def pozadina():
- try:
- print ''
- print '
'
-
- except:
- divGreska()
-
-
-#==========================================================================================
-
-print ' '
-
-if 'funkc' in form:
- #---------------------------------------
- if form.getvalue('funkc') == 'mjerpost':
- if 'kpost' in form:
- mjerenjaPostaje()
-
- #---------------------------------------
- if form.getvalue('funkc') == 'infopost':
- if 'kpost' in form:
- infoPostaje()
-
- #------------------------------------------
- if form.getvalue('funkc') == 'puninfopost':
- if 'kpost' in form:
- punInfoPostaje()
-
- #------------------------------------------
- if form.getvalue('funkc') == 'bilten':
- Bilten()
-
- #------------------------------------------
- if form.getvalue('funkc') == 'xbilten':
- BiltenX()
-
- #------------------------------------------
- if form.getvalue('funkc') == 'profilpost':
- if 'kpost' in form:
- profilPostaje()
-
- #---------------------------------------
- if form.getvalue('funkc') == 'slivvod':
- if ('ksliv' in form) and ('kvod' in form):
- slivVodInfo()
-
- #---------------------------------------
- if form.getvalue('funkc') == 'pozadina':
- pozadina()
-
-print ''
-
-if fbcon:
- fbcon.close()