;{ DDT SESTAVA - STANDARD } ;{ Export skladových položek pro eshop Sabanero } ;{ Verze: 3. 1.2018 } ;{ Autor: Milan Slíva } Name('Export Sabanero') Designed('SKL_MAN#1') Author('Milan Slíva','EMail: sliva@fi.cz','http://www.fi.cz') Descr('Export skladových polože ve formátu XML pro eshop Sabanero') ;{*******************************************************************************************************************************} WNSType(-1) DeclareRec('Program') DeclareRec('Sklad') DeclareRec('KeySklad1') DeclareRec('Ciselnik') DeclareRec('KeyCiselnik1') Ciselnik2 :Ciselnik f :TextFile Veta :LongInt Pozn :Note Stav :LongInt Pocet :LongInt Chyba :String INIPath :String=DataPath+'sabanero.ini' LocBo :Boolean LocBo2 :Boolean LocBo3 :Boolean VetaF :LongInt Veta :LongInt VetaC :LongInt CodeStr :String[32] LastCode :String[32] WeightStr :String[32] WeightUnit:String[2] ProcDPH :Byte FlagsCount:Byte ;{*******************************************************************************************************************************} ;{nacteni ini} Post:Boolean=GetBoolean(GetFromIni('Global','Post',INIPath)) Server :String=GetFromIni('Global','Server',INIPath) Uzivatel:String=GetFromIni('Global','Uzivatel',INIPath) Heslo :String=GetFromIni('Global','Heslo',INIPath) Soubor :String=GetFromIni('Global','Soubor',INIPath) if(Length(Soubor)=0) begin Soubor=WorkPath+'sabanero.xml' end; Odeslat:Boolean Ulozit:Boolean if(Post) Odeslat=True else Ulozit=True ;{*******************************************************************************************************************************} ;{formulář} DefDialog('Export ceníku',445,288) DlgShade(-1,'',5,5,435,210) DlgRadioButton(101,Odeslat,15,15,190,,'Upload na server',101,102) DlgStatic(-1,'Adresa',16,42,200,16) DlgEdit(110,Server,15,60,415) DlgStatic(-1,'Uživatel',15,87,200,16) DlgEdit(120,Uzivatel,16,105,200) DlgStatic(-1,'Heslo',230,87,200,16) DlgEdit(130,Heslo,230,105,200,,,es_Password) DlgRadioButton(102,Ulozit,16,150,190,,'Uložit do souboru',101,102) DlgStatic(-1,'Název souboru',16,184,112); DlgEdit(140,Soubor,128,180,236) DlgFileButton(140,364,179); DlgDivider(10,139,425,0); DlgButton(id_OK,'OK',305,222); DlgOnLineHelp(id_OK,'Pokračuje ve zpracování') DlgButton(id_Cancel,'Zpět',375,222); DlgOnLineHelp(id_Cancel,'Ukončí bez zpracování') Result:Integer=DlgExecute() if(Result=ID_Cancel) Halt ;{*******************************************************************************************************************************} ;{ulozeni ini} SetToIni('Global','Server',Server,INIPath) SetToIni('Global','Uzivatel',Uzivatel,INIPath) SetToIni('Global','Heslo',Heslo,INIPath) SetToIni('Global','Soubor',Soubor,INIPath) SetToIni('Global','Post',Odeslat,INIPath) ;{*******************************************************************************************************************************} ;{trideni dat} ClearRec(Ciselnik) ClearRec(Ciselnik2) Record Klic Length :Byte Code :Array[1..32] of Char; Relation :Byte Material :Array[1..14] of Char; SpolRok :Word; SpolCislo:LongInt; end; MakeTempFile(,Klic,false,false) ClearKey(KeySklad1) InitStatus(UsedKeys(KeySklad1),'Třídím data...') While(NextKey(KeySklad1,Veta)) begin ReadRec(Sklad,Veta) if((InFilter(Sklad))and(Sklad.TypKarty<2)and(Sklad.ShopFlags&1<>0)and(Sklad.CenaD>0)) begin ClearRec(Klic) Klic.Length=SizeOf(Klic)-1 if((Length(Sklad.ShopCode)<>0) and (Sklad.Material<>Sklad.ShopCode)) Inc(Klic.Relation) if(Length(Sklad.ShopCode)=0) Sklad.ShopCode=Sklad.Material StrToChars(Klic.Code,Sklad.ShopCode,#0) StrToChars(Klic.Material,Sklad.Material,#0) Klic.SpolRok=Swap(Sklad.SpolRok) Klic.SpolCislo=SwapL(Sklad.SpolCislo) AddKey(Klic,Veta) end Inc(Stav) SetStatus(Stav) end ;{*******************************************************************************************************************************} ;{otevreni souboru} if(Odeslat) Soubor=GetTempFileName() ReWrite(f,Soubor,True) ;{*******************************************************************************************************************************} ;{export} WriteLn(f,'') WriteLn(f,'') Stav=0 ClearKey(Klic) InitStatus(UsedKeys(Klic),'Exportuji data...') While(NextKey(Klic,Veta)) begin CodeStr=ToChar(#0,CharsToStr(Klic.Code)) ReadRec(Sklad,Veta) if(not CompareStr(CodeStr,LastCode)) begin if(Length(LastCode)<>0) begin WriteLn(f,#9#9,'') WriteLn(f,#9,'') end; LastCode=CodeStr Write(f,#9,'') if(Length(Sklad.LongText)=0) Sklad.LongText=Sklad.Nazev WriteLn(f,#9#9,'',XMLStr(Sklad.LongText),'') Open(Pozn) GetNote(Pozn,note_eshop,Sklad.SpolRok,Sklad.SpolCislo) Write(f,#9#9,'') WriteNote(f,Pozn,True,True) WriteLn(f,'') GetNote(Pozn,note_text,Sklad.SpolRok,Sklad.SpolCislo) if(Length(Pozn)<>0) begin Write(f,#9#9,'') WriteNote(f,Pozn,True,True) WriteLn(f,'') end; GetNote(Pozn,note_specifikace,Sklad.SpolRok,Sklad.SpolCislo) if(Length(Pozn)<>0) begin Write(f,#9#9,'') WriteNote(f,Pozn,True,True) WriteLn(f,'') end; GetNote(Pozn,note_stopy,Sklad.SpolRok,Sklad.SpolCislo) if(Length(Pozn)<>0) begin Write(f,#9#9,'') WriteNote(f,Pozn,True,True) WriteLn(f,'') end; GetNote(Pozn,note_navod,Sklad.SpolRok,Sklad.SpolCislo) if(Length(Pozn)<>0) begin Write(f,#9#9,'') WriteNote(f,Pozn,True,True) WriteLn(f,'') end; GetNote(Pozn,note_hodnoty,Sklad.SpolRok,Sklad.SpolCislo) if(Length(Pozn)<>0) begin Write(f,#9#9,'') WriteNote(f,Pozn,True,True) WriteLn(f,'') end; GetNote(Pozn,note_skladovani,Sklad.SpolRok,Sklad.SpolCislo) if(Length(Pozn)<>0) begin Write(f,#9#9,'') WriteNote(f,Pozn,True,True) WriteLn(f,'') end; GetNote(Pozn,note_puvod,Sklad.SpolRok,Sklad.SpolCislo) if(Length(Pozn)<>0) begin Write(f,#9#9,'') WriteNote(f,Pozn,True,True) WriteLn(f,'') end; GetNote(Pozn,note_slozeni,Sklad.SpolRok,Sklad.SpolCislo) if(Length(Pozn)<>0) begin Write(f,#9#9,'') WriteNote(f,Pozn,True,True) WriteLn(f,'') end; WriteLn(f,#9#9,'') end; Write(f,#9#9#9,''); Inc(Pocet) Inc(Stav) SetStatus(Stav) end if(Length(LastCode)<>0) begin WriteLn(f,#9#9,'') WriteLn(f,#9,'') end; WriteLn(f,'') Close(f) ;{*******************************************************************************************************************************} ;{odeslání} if(Odeslat) begin NewPost(); AddToPost('FileIncluded','1') AddToPost('FilesKey','sklad') AddToPost('FilesExt','.xml') AddToPost('SumItem',Pocet) AddFileToPost('sklad',Soubor); HTTPPost(Server,'sklexagc.log',Uzivatel,Heslo) end ;{*******************************************************************************************************************************} END