clear
set century on
set date german
set exclusive off
set confirm on
set console off
SET SAFETY OFF
set status bar off
set talk off
set deleted on
SET REPROCESS TO AUTOMATIC system
SET OPTIMIZE ON
SET MULTILOCKS on

CLOSE DATABASES

set sysmenu save
SET SYSMENU OFF
DEACTIVATE WINDOW "Standard"
putanja=CURDIR()
set default to &putanja

USE firma
mopcija=firma.opcioni
CLOSE databases
SET DEFAULT TO &putanja
set path to &mopcija

USE parame
nazfir=ALLTRIM(naziv)+" "+ALLTRIM(naziv1)
CLOSE databases

MODIFY WINDOW SCREEN TITLE 'Robno poslovanje :'+nazfir icon file folder0.ico

WITH _Screen
.WindowState = 2 
.MaxHeight=735
.MaxWidth=1020
.MaxButton=.f.
.Closable=.f.
.AutoCenter=.t.
.backcolor=0
.movable=.f.
.left=6
.top=25
.fontbold=.t.
.fontsize=14
*.maxbutton=.f.
ENDWITH


******************* kupdob   ************************
public 	m.sifkupdob, m.naz1kupdob,m.naz2kupdob, m.adrkupdob, m.meskupdob, m.faxkupdob, m.zirkupdob
PUBLIC	M.pibKUPDOB, M.PDVKUPDOB

m.sifkupdob=SPACE(6)
m.naz1kupdob=SPACE(50)
m.naz2kupdob=SPACE(50)
m.adrkupdob=SPACE(30)
m.meskupdob=SPACE(30)
m.faxkupdob=SPACE(20)
m.zirkupdob=SPACE(20)
m.pibkupdob=SPACE(9)
m.pdvkupdob=SPACE(1)

******************* Firma    ************************
PUBLIC m.firma, m.adresa, M.MESTO, m.telefon, m.radnik, m.prio, m.kurs
m.firma=SPACE(60)
m.adresa=SPACE(30)
m.mesto=SPACE(30)
m.telefon=SPACE(25)
m.radnik=SPACE(4)
m.prio=0
m.kurs=0
******************* komercijalista **********************************
public	m.sifrad, m.nazrad
m.sifrad=SPACE(4)
m.nazrad=SPACE(20)

******************** proizvodjaci ****************************
PUBLIC m.proizvod, m.nazpro
m.proizvod=SPACE(6)
m.nazpro=SPACE(30)

********************* robne grupe **************************
PUBLIC m.grupa, m.nazgru
m.grupa=SPACE(4)
m.nazgru=SPACE(30)


********************* roba *****************************
PUBLIC m.sifrob,m.barkod, m.nazrob, m.jm, m.tarrob
m.sifrob=SPACE(13)
m.barkod=SPACE(13)
m.nazrob=SPACE(50)
m.jm=SPACE(3)
m.tarrob=SPACE(2)


********************************************************


PUBLIC oli, m.tarifa, KSTAJE, m.koef, fstaje, m.spor, m.matkupdob
PUBLIC m.magacin, m.brdok, helpkod, mtarifa, mstopa
PUBLIC m.snvre, m.smar, m.spor, m.srab, m.spvre, mrb, m.ncena, m.pcena, mporez, mmarza
pUBLIC m.kolicina, m.maticni, m.registar, m.delatnost, m.ziro, m.brojdana
PUBLIC merror, mess, mess1, mprog, mlineno, mkstaje, mfstaje,m.r1,m.slovima,m.rokpla
PUBLIC olir1,m.sdug,m.spot,m.radnik,m.uvecanje,m.ukupor,m.zavisni, mobrpor
PUBLIC mizjava, mdatizj, m.razduz, m.gotova, m.paragon, m.datod, m.datdo, m.malopor, m.malomar
PUBLIC m.nazgru, m.grupa, m.proizvod, m.nazpro, m.pib, m.pepdv
oli=SPACE(1)
m.kolicina=0
m.radnick=SPACE(20)
m.sifrad=SPACE(4)
m.prio=0
m.textpor=SPACE(2)
m.brdok=SPACE(9)
m.razduz="D"
m.gotova=.f.
m.snvre=0
m.smar=0
m.spor=0
m.srab=0
m.spvre=0
m.pcena=0
m.ncena=0
mrb=0
mizjava=SPACE(15)
mdatizj=DATE()
mobrpor=SPACE(1)
m.r1=SPACE(1)
m.sifrob=SPACE(13)
kstaje=SPACE(1)
fstaje=SPACE(1)
mktaje=SPACE(1)
mfstaje=SPACE(1)
mporez=0
mmarza=0
mtarifa=SPACE(3)
mstopa=0
m.slovima=SPACE(1)
m.brojdana=0
m.rokpla=SPACE(60)
olir1=SPACE(2)
m.sdug=0
m.spot=0
m.radnik=SPACE(4)
m.uvecanje=0
m.ukupor=0
m.zavisni=0
m.paragon=0
m.datod=DATE()
m.datdo=DATE()
m.malopor=0
m.malomar=0
ON ERROR do greska with ;
	ERROR(),MESSAGE(),MESSAGE(1),PROGRAM(),LINENO()


helpkod=SPACE(10)
	CLOSE databases
	DO krebaza
	CLOSE all
	DO otvaranje
	ON ERROR do greska with ;
	ERROR(),MESSAGE(),MESSAGE(1),PROGRAM(),LINENO()

DO FORM lozinka
read event
CLOSE DATABASES
return



procedure sve_proc

return
***************************************************

procedure otvaranje
OPEN DATABASE robno SHARED

USE radnici  SHARED ORDER tag sifra ALIAS radnici IN 0
*USE tarife  SHARED ORDER tag sifra ALIAS tarife IN 0
USE parame ALIAS parame SHARED IN 0
	m.kurs	 =parame.kurs
	m.firma	 =parame.naziv
	m.adresa =parame.adresa
	m.mesto  =parame.ptt+" "+parame.mesto
	m.telefon=parame.tel1
	m.maticni=parame.maticni
	m.registar=parame.registar
	m.delatnost=parame.delatnost
	m.ziro   =parame.ziro
	m.malopor=parame.porez
	m.malomar=parame.marza
	m.pib	=parame.pib
	m.pepdv	=parame.pepdv
*USE magacin ALIAS magacin SHARED IN 0
USE kupdob ALIAS kupdob SHARED IN 0
USE GRESKA ALIAS GRESkA SHARED IN 0
USE roba ALIAS roba SHARED IN 0
USE grupa ALIAS grupa SHARED IN 0
USE proizvod ALIAS proizvod SHARED IN 0

USE firma  EXCLUSIVE ALIAS firma IN 0


RETURN




******************************************************************
PROCEDURE krebaza

	
ERASE karkom.dbf
ERASE karkom.cdx
CREATE TABLE karkom ;
	(datum		d(8),;
	kupdob		c(6),;
	nazkom		c(30),;
	tel1		c(20),;
	tel2		c(20),;
	dokument	c(10),;
	brdok		c(9),;
	magacin		c(2),;
	duguje		n(15,2),;
	potrazuje	n(15,2),;
	vrsta		c(2),;
	valuTa		d(8),;
	iznos		n(15,2),;
	dospelo		n(15,2))

ERASE nekupci.dbf
ERASE nekupci.cdx
CREATE TABLE nekupci ;
	(datum		d(8),;
	kupdob		c(6),;
	nazkom		c(30),;
	tel1		c(20),;
	tel2		c(20),;
	dokument	c(10),;
	brdok		c(9),;
	magacin		c(2),;
	duguje		n(15,2),;
	potrazuje	n(15,2),;
	vrsta		c(2),;
	valuTa		d(8),;
	iznos		n(15,2),;
	dospelo		n(15,2))

ERASE izfak.dbf
ERASE izfak.cdx
CREATE TABLE izfak ;
	(datum		d(8),;
	kupdob		c(6),;
	nazkom		c(30),;
	tel1		c(20),;
	tel2		c(20),;
	dokument	c(10),;
	brdok		c(9),;
	magacin		c(2),;
	duguje		n(15,2),;
	potrazuje	n(15,2),;
	vrsta		c(2),;
	valuTa		d(8),;
	iznos		n(15,2),;
	dospelo		n(15,2))

ERASE karsvi.dbf
ERASE karsvi.cdx
CREATE TABLE karsvi ;
	(datum		d(8),;
	kupdob		c(6),;
	nazkom		c(30),;
	tel1		c(20),;
	tel2		c(20),;
	dokument	c(10),;
	brdok		c(9),;
	magacin		c(2),;
	duguje		n(15,2),;
	potrazuje	n(15,2),;
	vrsta		c(2),;
	valuTa		d(8),;
	iznos		n(15,2),;
	dospelo		n(15,2))

ERASE topkup.dbf
ERASE topkup.cdx
CREATE TABLE topkup ;
	(datum		d(8),;
	kupdob		c(6),;
	nazkom		c(30),;
	tel1		c(20),;
	tel2		c(20),;
	dokument	c(10),;
	brdok		c(9),;
	magacin		c(2),;
	duguje		n(15,2),;
	potrazuje	n(15,2),;
	vrsta		c(2),;
	valuTa		d(8),;
	iznos		n(15,2),;
	dospelo		n(15,2))

ERASE karrob.dbf
ERASE karrob.cdx
CREATE TABLE karrob;
	(datum		d(8),;
	sifrob		c(13),;
	kupdob		c(6),;
	nazdob		c(30),;
	nazrob		c(30),;
	dokument	c(10),;
	brdok		c(9),;
	ukolicina	n(12,3),;
	ikolicina	n(12,3),;
	kolicina	n(12,3),;
	ncena		n(15,2),;
	pcena		n(15,2),;
	rabat		n(6,2),;
	marza		n(15,2),;
	stvacen		n(15,2),;
	stanje		n(15,3))
	
ERASE PORUCI.dbf
ERASE PORUCI.cdx
CREATE TABLE PORUCI;
	(datum		d(8),;
	sifrob		c(13),;
	kupdob		c(6),;
	nazdob		c(30),;
	nazrob		c(30),;
	dokument	c(10),;
	brdok		c(9),;
	ukolicina	n(12,3),;
	ikolicina	n(12,3),;
	kolicina	n(12,3),;
	ncena		n(15,2),;
	pcena		n(15,2),;
	rabat		n(6,2),;
	marza		n(15,2),;
	stvacen		n(15,2),;
	stanje		n(15,3))

ERASE kuprob.dbf
ERASE kuprob.cdx
CREATE TABLE kuprob;
	(datum		d(8),;
	kupdob		c(6),;
	nazdob		c(30),;
	sifrob		c(13),;
	nazrob		c(30),;
	dokument	c(10),;
	brdok		c(9),;
	ukolicina	n(12,3),;
	ikolicina	n(12,3),;
	ncena		n(15,2),;
	pcena		n(15,2),;
	rabat		n(6,2),;
	marza		n(15,2),;
	stvacen		n(15,2),;
	stanje		n(12,3))

ERASE promkup.dbf
ERASE promkup.cdx
CREATE TABLE promkup;
	(datum		d(8),;
	kupdob		c(6),;
	nazdob		c(30),;
	sifrob		c(13),;
	nazrob		c(30),;
	dokument	c(10),;
	brdok		c(9),;
	ukolicina	n(12,3),;
	ikolicina	n(12,3),;
	ncena		n(15,2),;
	pcena		n(15,2),;
	rabat		n(6,2),;
	marza		n(15,2),;
	stvacen		n(15,2),;
	stanje		n(12,3))

ERASE llista.dbf
ERASE llista.cdx
CREATE TABLE llista;
	(rb			n(5),;
	magacin		c(2),;
	sifrob		c(13),;
	naziv		c(30),;
	jm			c(3),;
	kolicina	n(12,3),;
	ikol		n(12,3),;
	pcen		n(15,2),;
	ncen		n(15,2),;
	kod			n(1))

ERASE paragon.dbf
CREATE TABLE paragon;
	(datum		d(8),;
	brdok		n(5),;
	sifra		c(13),;
	naziv		c(30),;
	cena		n(15,2),;
	kolicina	n(15,3))
	
ERASE pfakstav.dbf
ERASE pfakstav.cdx
CREATE TABLE pfakstav;
	(brdok		c(9),;
	rb			n(3),;
	naziv		c(30),;
	sifrar		c(13),;
	sifrob		c(13),;
	magacin		c(2),;
	datum		d(8),;
	kupdob		c(6),;
	kolicina	n(15,3),;
	ncena		n(15,2),;
	tarifa		c(3),;
	marza		n(7,2),;
	rabat		n(6,2),;
	npcena		n(15,2),;
	pcena		n(15,2),;
	stopa		n(6,2),;
	porez		n(15,2),;
	euro		n(15,2),;
	obrpor		c(1),;
	zavtros		n(15,2),;
	jm			c(3),;
	cenasapor	n(15,2),;
	pvrednost	n(15,2),;
	razduz		c(1),;
	kod			c(1))


ERASE pklkstav.dbf
ERASE pklkstav.cdx
CREATE TABLE pkalkstav;
	(brdok		c(9),;
	rb			n(3),;
	naziv		c(30),;
	sifrar		c(13),;
	sifrob		c(13),;
	magacin		c(2),;
	datum		d(8),;
	kupdob		c(6),;
	kolicina	n(15,3),;
	ncena		n(15,2),;
	tarifa		c(3),;
	marza		n(7,2),;
	rabat		n(6,2),;
	npcena		n(15,2),;
	pcena		n(15,2),;
	stopa		n(6,2),;
	porez		n(15,2),;
	euro		n(15,2),;
	obrpor		c(1),;
	zavtros		n(15,2),;
	jm			c(3),;
	cenasapor	n(15,2),;
	pvrednost	n(15,2),;
	ceneur		n(15,2),;
	akciza		c(1),;
	razduz		c(1),;
	kod			c(1))

ERASE procenti.dbf
CREATE TABLE procenti;
	(procenat	c(3),;
	iznos		n(15,2))



ERASE robkar.dbf
ERASE robkar.cdx
CREATE TABLE robkar;
	(datum		d(8),;
	oznaka		c(1),;
	kupdob		c(6),;
	nazdob		c(30),;
	sifrob		c(13),;
	nazrob		c(30),;
	dokument	c(10),;
	brdok		c(9),;
	ukolicina	n(15,3),;
	ikolicina	n(15,3),;
	ncena		n(15,2),;
	pcena		n(15,3),;
	rabat		n(6,2),;
	marza		n(15,2),;
	stvacen		n(15,2),;
	stanje		n(15,3))

ERASE robizl.dbf
ERASE robizl.cdx
CREATE TABLE robizl;
	(datum		d(8),;
	oznaka		c(1),;
	kupdob		c(6),;
	nazdob		c(30),;
	sifrob		c(13),;
	nazrob		c(30),;
	dokument	c(10),;
	brdok		c(9),;
	ukolicina	n(15,3),;
	ikolicina	n(15,3),;
	ncena		n(15,2),;
	pcena		n(15,3),;
	rabat		n(6,2),;
	marza		n(15,2),;
	stvacen		n(15,2),;
	stanje		n(15,3))

ERASE robizl2.dbf
ERASE robizl2.cdx
CREATE TABLE robizl2;
	(datum		d(8),;
	oznaka		c(1),;
	kupdob		c(6),;
	nazdob		c(30),;
	sifrob		c(13),;
	nazrob		c(30),;
	dokument	c(10),;
	brdok		c(9),;
	ukolicina	n(15,3),;
	ikolicina	n(15,3),;
	ncena		n(15,2),;
	pcena		n(15,3),;
	rabat		n(6,2),;
	marza		n(15,2),;
	stvacen		n(15,2),;
	stanje		n(15,3))

ERASE toprob.dbf
ERASE toprob.cdx
CREATE TABLE toprob;
	(datum		d(8),;
	oznaka		c(1),;
	kupdob		c(6),;
	nazdob		c(30),;
	sifrob		c(13),;
	nazrob		c(30),;
	dokument	c(10),;
	brdok		c(9),;
	ukolicina	n(15,3),;
	ikolicina	n(15,3),;
	ncena		n(15,2),;
	pcena		n(15,3),;
	rabat		n(6,2),;
	marza		n(15,2),;
	stvacen		n(15,2),;
	stanje		n(15,3))

ERASE toprob1.dbf
ERASE toprob1.cdx
CREATE TABLE toprob1;
	(datum		d(8),;
	oznaka		c(1),;
	kupdob		c(6),;
	nazdob		c(30),;
	sifrob		c(13),;
	nazrob		c(30),;
	dokument	c(10),;
	brdok		c(9),;
	ukolicina	n(15,3),;
	ikolicina	n(15,3),;
	ncena		n(15,2),;
	pcena		n(15,3),;
	rabat		n(6,2),;
	marza		n(15,2),;
	stvacen		n(15,2),;
	stanje		n(15,3))

ERASE prokol.dbf
ERASE prokol.cdx
CREATE TABLE prokol;
	(datum		d(8),;
	oznaka		c(1),;
	kupdob		c(6),;
	nazdob		c(30),;
	sifrob		c(13),;
	nazrob		c(30),;
	dokument	c(10),;
	brdok		c(9),;
	ukolicina	n(15,3),;
	ikolicina	n(15,3),;
	ncena		n(15,2),;
	pcena		n(15,3),;
	rabat		n(6,2),;
	marza		n(15,2),;
	stvacen		n(15,2),;
	stanje		n(15,3))


ERASE ropokup.dbf
ERASE ropokup.cdx
CREATE TABLE ropokup;
	(sifra		c(13),;
	naziv		c(30),;
	jm			c(3),;
	kolicina	n(15,3),;
	kolicina1	n(15,3),;
	sifra1		c(13),;
	naziv1		c(30),;
	jm1			c(3),;
	pcena		n(15,2),;
	ncena		n(15,2),;
	marza		n(6,2),;
	oznaka		c(1))

ERASE toprob2.dbf
ERASE toprob2.cdx
CREATE TABLE toprob2;
	(sifrob		c(13),;
	nazrob		c(30),;
	jm			c(3),;
	kolicina	n(15,3),;
	vrednost	n(15,2))

ERASE upolag.dbf
ERASE upolag.cdx
CREATE 	table upolag;
	(sifra		c(13),;
	scg			n(1),;
	bih			n(1),;
	cro			n(1),;
	naziv		c(30),;
	jm			c(3),;
	kolscg		n(12,3),;
	kolbih		n(12,3),;
	kolcro		n(12,3),;
	proscg		n(12,3),;
	probih		n(12,3),;
	procro		n(12,3))

ERASE psklop.dbf
ERASE psklop.cdx
CREATE TABLE psklop;
	(sklop		c(13),;
	element		c(13),;
	naziv		c(30),;
	kolicina	n(12,3))

ERASE pkros.dbf
ERASE pkros.cdx
CREATE TABLE pkros;
	(proizvod	c(30),;
	oem			c(20),;
	cargo		c(13),;
	napomena	c(30))


ERASE PKONKUP.DBF
CREATE TABLE PKONKUP;
	(KUPDOB		C(6),;
	DATUM		D(8),;
	VREME		C(8),;
	NAPOMENA	C(100),;
	ZVAO		C(10),;
	staje		n(1))
	
ERASE ptraznja.dbf
CREATE TABLE ptraznja;
	(kupdob		c(6),;
	datum		d(8),;
	nazrob		c(30),;
	vreme		c(8),;
	sifrob		c(13),;
	kolicina	n(12,3),;
	cena		n(15,2),;
	staje		n(1),;
	rabat		n(6,2),;
	zvao		c(10))
	
ERASE ptraznja1.dbf
CREATE TABLE ptraznja1;
	(kupdob		c(6),;
	datum		d(8),;
	nazrob		c(30),;
	vreme		c(8),;
	sifrob		c(13),;
	kolicina	n(12,3),;
	cena		n(15,2),;
	staje		n(1),;
	rabat		n(6,2),;
	zvao		c(10))
RETURN


******************************************************************

FUNCTION okom(mmkupdob)
SELECT kupdob
SET ORDER TO tag kupdob
GOTO top
SEEK mmkupdob
IF !FOUND()
	=MESSAGEBOX("Zao mi je ali takav kupac ne postoji","Upozorenje",48)
ELSE
	m.sifkupdob=kupdob.kupdob
	m.nazkupdob=kupdob.naziv
	m.adrkupdob=kupdob.adresa
	m.meskupdob=kupdob.mesto
ENDIF

RETURN
****************************************


FUNCTION poruka(porukica)
=MESSAGEBOX(porukica,"Poruka!!!!",48)
RETURN



***********************************************************************
FUNCTION nadjikom(mmkupdob)

SELECT kupdob
SET ORDER TO tag kupdob
GOTO top
SEEK mmkupdob
IF !FOUND()
	*=PORUKA("Zao mi je ali takav kupac ne postoji")
ELSE
	m.sifkupdob=kupdob.kupdob
	m.nazkupdob=kupdob.naziv
	m.adrkupdob=kupdob.adresa
	m.meskupdob=kupdob.mesto
ENDIF

RETURN



*************************************************************************
PROCEDURE fenix
CLOSE ALL
*DO FORM indexiraj
CLOSE ALL
open database belcar shared	
DO otvaranje
RETURN

*************************************************************
FUNCTION rolock()
DO WHILE !RLOCK()
=MESSAGEBOX("Neko je zakljucao slog","Poruka!",0,1)
ENDDO
RETURN

************************************************************
FUNCTION robica()
PARAMETERS mrobica
SELECT zalihe
SET ORDER to tag zalihe
GOTO top
LOCATE FOR m.magacin=magacin .and. m.sifrob=sifra
m.ncena=zalihe.nabcen
m.pcena=zalihe.procen
kolicina=zalihe.ukol-zalihe.ikol
RETURN (kolicina)


************************************************************
PROCEDURE greska
PARAMETER gr1,gr2,gr3,gr4,gr5
merror=gr1
mess=gr2
mess1=gr3
mprog=gr4
mlineno=gr5
SELECT greska
APPEND BLANK
replace datum WITH DATE()
replace vreme WITH TIME()
replace greska WITH merror
replace por	WITH mess
replace por1 WITH mess1
replace pro WITH mprog
replace lini	WITH mlineno
replace radnik WITH m.sifrad
DO FORM greska
RETURN

*********************************************************************

        **********************************************************************



FUNCTION fgrupa(msifra)
SELECT grupa 
SET ORDER TO tag grupa
GOTO top
SEEK msifra
m.nazgru=grupa.naziv
RETURN .t.



************* funkcije ******************************

********** slovima **************************

function SLOVIMA( broj )
DECLARE imebr[9]
  local _trojka,;
  tric,;
  cs,;
  cd,;
  cj,;
  sl1

  imebr[1]="jedan"
  imebr[2]="dva"
  imebr[3]="tri"
  imebr[4]="cetiri"
  imebr[5]="pet"
  imebr[6]="sest"
  imebr[7]="sedam"
  imebr[8]="osam"
  imebr[9]="devet"

  rez   = " "
  celi  = int( broj )
  dec   = ( broj - celi ) * 100
  cbroj = str( celi, 15 )
  i     = 1

  if broj == 0 
           return "nula" 
  endif

    DO while ( i < 15 )
      tric    = substr( cbroj, i, 3 )
      _trojka = val( tric )
      if tric # "   " .and. ( tric # "000" .or. i = 4 )
        cs = val( substr( tric, 1, 1 ) )
        cd = val( substr( tric, 2, 1 ) )
        cj = val( substr( tric, 3, 1 ) )
        do case
          case cs = 1
            rez = rez+ "sto"
          case cs = 2
            rez = rez+ "dve"
          case cs > 2
            rez = rez+ imebr[cs]
        endcase
        do case
          case cs > 4
            rez = rez+ "stotina"
          case cs > 1
            rez =rez+ "stotine"
        endcase
        sl1 = iif( cj = 0, "", imebr[cj] )
        do case
          case cd =4
            rez =rez+ "cetr"
          case cd = 5
            rez =rez+ "pe"
          case cd = 6
            rez =rez+ "sez"
          case cd = 9
            rez =rez+ "deve"
          case cd > 1
            rez =rez+ imebr[cd]
          case cd = 1
            sl1 = ""
            do case
              case cj = 0
                rez =rez+ "deset"
              case cj = 1
                rez =rez+ "jeda"
              case cj = 4
                rez =rez+ "cetr"
              otherwise
                rez =rez+ imebr[cj]
            endcase
            if cj > 0 
            	 rez =rez+ "naest" 
          	endif
          endcase
          if cd > 1 
          	 rez =rez+ "deset" 
          endif
            do case
              case cj = 1 .and. ( i == 4 .or. i == 10 ) .and. cd # 1
                sl1 = "jedna"
              case cj = 2 .and. ( i == 4 .or. i == 10 ) .and. cd # 1
                sl1 = "dve"
            endcase
            rez =rez+ sl1
            do case
              case i = 1 .or. i == 10
                rez =rez+ "hiljad"
                do case
                  case ( _trojka % 100 > 11 .and. _trojka % 100 < 19 ) .or. cj == 1
                    rez =rez+ "a"
                  case _trojka = 1
                    rez =rez+ "u"
                  case cj > 4 .or. cj = 0
                    rez =rez+ "a"
                  case cj > 1
                    rez =rez+ "e"
                endcase
              case i = 4
                rez =rez+ "milijard"
                do case
                  case ( _trojka % 100 > 11 .and. _trojka % 100 < 19 )
                    rez =rez+ "i"
                  case cj = 1
                    rez =rez+ "a"
                  case cj > 4 .or. cj = 0
                    rez =rez+ "i"
                  case cj > 1
                    rez =rez+ "e"
                endcase
              case i = 7
                rez =rez+ "milion"
                if cj # 1 .or. ( _trojka % 100 > 11 .and. _trojka % 100 < 19 )
                  rez =rez+ "a"
                endif
            endcase
          endif
          i =i+ 3
        enddo
        return( rez + " i " + transform( dec, "@L 99" ) + "/100" )

***********************************************************************

***************** priprema za upis *********************
FUNCTION pripremi(mfile)
=CURSORSETPROP("Buffering",5,mfile)
return(0)

********************************************************

****************** upis u tabelu **********************
FUNCTION upisi()
BEGIN TRANSACTION 
	=TABLEUPDATE(1,.t.)
END TRANSACTION 
UNLOCK all
return(0)
*****************************************************

************** formatiranje vodecih nula kod automatskog sifriranja **********
FUNCTION formsif(mvarijabla,mduzina)
mvar1=ALLTRIM(STR(VAL(mvarijabla)+1))
ml=LEN(mvar1)
mvarijabla=REPLICATE("0",mduzina-ml)+mvar1
RETURN(mvarijabla)

**********************************************************************
PROCEDURE kraj
UNLOCK all
CLEAR ALL
CLOSE ALL
CLEAR EVENTS
RETURN

