Files
Kdynium-plgKdynium/frmOOPPohyb.pas
2025-05-21 21:19:51 +02:00

604 lines
21 KiB
ObjectPascal

unit frmOOPPohyb;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ExtCtrls, ddPlugin_TLB,
Vcl.Mask, RzEdit, RzBtnEdt, Vcl.ComCtrls, RzDTP, Vcl.NumberBox;
const
tblOOPProfese = '[dbo].[_hdc_TabOOP_Profese]';
tblOOPPolozky = '[dbo].[_hdc_TabOOP_Polozky]';
tblOOPPotrebnost = '[dbo].[_hdc_TabOOP_Potrebnost]';
tblOOPPohyby = '[dbo].[_hdc_TabOOP_Pohyby]';
tblOOPDuvod = '[dbo].[_hdc_TabOOP_Duvod]';
type
TformOOPPohyb = class(TForm)
edtOsCislo: TRzButtonEdit;
GroupBox1: TGroupBox;
Label1: TLabel;
edtPrijmJm: TRzButtonEdit;
Label2: TLabel;
Label3: TLabel;
edtProfese: TRzButtonEdit;
Label4: TLabel;
edtStredisko: TRzButtonEdit;
edtStrediskoText: TRzButtonEdit;
edtStrediskoOld: TEdit;
edtDatum: TRzDateTimePicker;
Label5: TLabel;
Label6: TLabel;
edtPolozka: TRzButtonEdit;
edtPolozkaText: TRzButtonEdit;
btnOK: TButton;
btnStorno: TButton;
edtMnoz: TNumberBox;
Label7: TLabel;
memoPozn: TMemo;
Label8: TLabel;
procedure edtOsCisloButtonClick(Sender: TObject);
procedure edtPrijmJmButtonClick(Sender: TObject);
procedure edtStrediskoButtonClick(Sender: TObject);
procedure edtProfeseButtonClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure edtOsCisloExit(Sender: TObject);
procedure btnStornoClick(Sender: TObject);
procedure edtPolozkaButtonClick(Sender: TObject);
procedure edtPolozkaExit(Sender: TObject);
procedure edtPolozkaEnter(Sender: TObject);
procedure btnOKClick(Sender: TObject);
procedure edtOsCisloKeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure edtPolozkaKeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure edtPrijmJmKeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
private
function NactiUdajeZamestnance(cisZam: integer): boolean;
function MamNarokNaPolozku(var outMsg: string): boolean;
procedure DotazNaUkonceni;
public
Helios: IHelios;
jeTest: boolean;
end;
var
formOOPPohyb: TformOOPPohyb;
bidOOPProfese, bidOOPPolozky: integer;
outMsg: string;
cisZam, idZam, idZamUser: integer;
stredisko, strediskoUser, profese, polozka, polozkaNum, stredOld: string;
idProf, idPolozka: integer;
oVar1, oVar2: OleVariant;
infoUkazano, superUserOOP: boolean;
implementation
uses System.StrUtils, System.DateUtils, System.UITypes,
helUtils;
{$R *.dfm}
procedure TaskDlgOK(titulek, nadpis, textX: string; ikona: byte);
begin
with TTaskDialog.Create(nil) do
begin
try
Caption:= titulek;
Title:= nadpis;
Text:= textX;
MainIcon:= ikona;
DefaultButton:= tcbOK;
CommonButtons:= [tcbOk];
Execute;
finally
Free;
end;
end;
end;
function TaskDlgYesNo(titulek, nadpis, textX: string; ikona: byte; defBtn: TTaskDialogCommonButton): System.UITypes.TModalResult;
begin
with TTaskDialog.Create(nil) do
begin
try
Caption:= titulek;
Title:= nadpis;
Text:= textX;
MainIcon:= ikona;
DefaultButton:= defBtn;
CommonButtons:= [tcbYes, tcbNo];
Execute;
result:= ModalResult;
finally
Free;
end;
end;
end;
procedure TformOOPPohyb.DotazNaUkonceni;
begin
if ((TaskDlgYesNo('', 'Chcete ukončit zadávání ?', '(data nebudou uložena)', tdiInformation, tcbNo))=mrYes) then
Close;
end;
function TformOOPPohyb.NactiUdajeZamestnance(cisZam: Integer): Boolean;
begin
result:= false;
if (cisZam>0) then
begin
if (helUtils.sqlExistsTestGeneral(Helios, 'SELECT 1 FROM ' + tblCisZam + ' WHERE Cislo=' + cisZam.ToString)) then
begin
idZam:= helUtils.getHeliosIntVal(Helios, 0, 'SELECT ID FROM ' + tblCisZam + ' WHERE Cislo=' + cisZam.ToString);
if (idZam>0) and (helUtils.sqlExistsTestGeneral(Helios, 'SELECT 1 FROM (VALUES(1)) t1(col1) WHERE COL_LENGTH(N' + tblCisZamE.QuotedString + ', N''_OOP_Profese'') IS NOT NULL')) then
begin
idProf:= helUtils.getHeliosIntVal(Helios, 0, 'SELECT ISNULL(_OOP_Profese, 0) FROM ' + tblCisZamE + ' WHERE ID=' + idZam.ToString);
if (idProf>0) then
begin
edtProfese.Text:= helUtils.getHeliosStrVal(Helios, '', 'SELECT Profese FROM ' + tblOOPProfese + ' WHERE ID=' + idProf.ToString);
if (edtDatum.CanFocus) then
edtDatum.SetFocus;
end
else
edtProfese.Text:= '';
end;
edtPrijmJm.Text:= helUtils.getHeliosStrVal(Helios, '', 'SELECT PrijmeniJmeno FROM ' + tblCisZam + ' WHERE Cislo=' + cisZam.ToString);
edtStredisko.Text:= helUtils.getHeliosStrVal(Helios, '', 'SELECT Stredisko FROM ' + tblCisZam + ' WHERE Cislo=' + cisZam.ToString);
edtStrediskoText.Text:= helUtils.getHeliosStrVal(Helios, '', 'SELECT Nazev FROM ' + tblStrom + ' WHERE Cislo=N' + edtStredisko.Text.QuotedString);
stredOld:= helUtils.getHeliosStrVal(Helios, '', 'SELECT TOP(1) StrediskoOld FROM ' + tblOOPProfese + ' WHERE Stredisko=N' + edtStredisko.Text.QuotedString);
edtStrediskoOld.Text:= stredOld;
result:= true;
end
end
else
begin
TaskDlgOK('POZOR', 'CHYBA', 'Uvedený zaměstnanec nebyl nalezen nebo nemáte právo jej vybrat.', tdiError);
edtOsCislo.Text:= '';
edtPrijmJm.Text:= '';
cisZam:= 0;
idZam:= 0;
end;
end;
procedure TformOOPPohyb.btnOKClick(Sender: TObject);
var lSQL: string;
begin
if (cisZam>0) and (idPolozka>0) then
begin
lSQL:= 'INSERT ' + tblOOPPohyby + ' (IDPolozky, Datum, CisloZam, Mnozstvi, Poznamka, IDProfese) SELECT ' + idPolozka.ToString + ', CONVERT(date, N'
+ edtDatum.DateTime.Format('').QuotedString + ', 104), ' + cisZam.ToString + ', ' + edtMnoz.Value.ToString + ', N' + IfThen(memoPozn.Text='', 'ULL', memoPozn.Text.QuotedString)
+ ', ' + IfThen(idProf=0, 'NULL', idProf.ToString);
Helios.ExecSQL(lSQL);
Close;
end
else
begin
TaskDlgOK('POZOR', 'CHYBA', 'Nebyly zadány všechny potřebné informace.', tdiWarning);
if (idPolozka=0) and (edtPolozka.CanFocus) then
edtPolozka.SetFocus;
if (cisZam=0) and (edtOsCislo.CanFocus) then
edtOsCislo.SetFocus;
end;
end;
procedure TformOOPPohyb.btnStornoClick(Sender: TObject);
begin
Close;
end;
procedure TformOOPPohyb.edtOsCisloButtonClick(Sender: TObject);
var c: integer;
podm: string;
begin
podm:= IfThen(superUserOOP, '', 'TabCisZam.Stredisko LIKE N' + (strediskoUser + '%').QuotedString);
podm:= podm + IfThen(podm<>'', ' AND ', '') + 'TabCisZam.ID IN (SELECT ZamestnanecID FROM ' + tblZamMzd + ' WHERE StavES=0 AND IdObdobi=(SELECT ID FROM ' + tblMzdObd + ' WHERE Rok='
+ YearOf(Now).ToString + ' AND Mesic=' + MonthOf(Now).ToString + ') AND ISNULL(DatumUkonceniPP, N''20991231'')>GETDATE() )';
if (Helios.Prenos(bidCisZam, 'TabCisZam.Cislo', oVar1, podm, 'Zaměstnanec', true)) then
begin
cisZam:= oVar1;
edtOsCislo.Text:= cisZam.ToString;
if (edtOsCislo.Text<>'') then
begin
if not(TryStrToInt(edtOsCislo.Text, c)) then
c:= 0;
cisZam:= c;
if (NactiUdajeZamestnance(cisZam)) then
if (edtProfese.CanFocus) then
edtProfese.SetFocus;
end
else
cisZam:= 0;
end;
if (edtOsCislo.Modified) then
begin
idPolozka:= 0;
edtPolozka.Text:= '';
edtPolozkaText.Text:= '';
end;
end;
procedure TformOOPPohyb.edtOsCisloExit(Sender: TObject);
var lSQL: string;
c: integer;
nulujZam: boolean;
begin
nulujZam:= true;
edtOsCislo.Text:= edtOsCislo.Text.Trim;
if (edtOsCislo.Text<>'') then
begin
nulujZam:= false;
if not(TryStrToInt(edtOsCislo.Text, c)) then
c:= 0;
cisZam:= c;
idZam:= helUtils.getHeliosIntVal(Helios, 0, 'SELECT ID FROM ' + tblCisZam + ' WHERE Cislo=' + cisZam.ToString);
if not(superUserOOP) then
if not(helUtils.sqlExistsTestGeneral(Helios, 'SELECT 1 FROM ' + tblCisZam + ' WHERE Cislo=' + cisZam.ToString + ' AND Stredisko LIKE N' + (strediskoUser + '%').QuotedString)) then
nulujZam:= true;
lSQL:= 'SELECT 1 FROM ' + tblZamMzd + ' WHERE ZamestnanecId=' + idZam.ToString + ' AND IdObdobi=(SELECT ID FROM ' + tblMzdObd + ' WHERE Rok=' + YearOf(Now).ToString
+ ' AND Mesic=' + MonthOf(Now).ToString + ') AND StavES=0 AND ISNULL(DatumUkonceniPP, N''20991231'')>GETDATE()';
if not(helUtils.sqlExistsTestGeneral(Helios, lSQL)) then
nulujZam:= true;
if (nulujZam) then
begin
cisZam:= 0;
idZam:= 0;
edtOsCislo.Text:= '';
edtPrijmJm.Text:= '';
end;
if (NactiUdajeZamestnance(cisZam)) then
if (edtProfese.CanFocus) then
edtProfese.SetFocus;
end;
if (edtOsCislo.Modified) then
begin
idPolozka:= 0;
edtPolozka.Text:= '';
edtPolozkaText.Text:= '';
end;
if (nulujZam) then
begin
cisZam:= 0;
idZam:= 0;
edtOsCislo.Text:= '';
edtPrijmJm.Text:= '';
end;
end;
procedure TformOOPPohyb.edtPrijmJmKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
if (Key=VK_ESCAPE) then
DotazNaUkonceni;
end;
procedure TformOOPPohyb.edtPolozkaKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
if (Key=VK_ESCAPE) then
DotazNaUkonceni;
end;
procedure TformOOPPohyb.edtOsCisloKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
if (Key=VK_ESCAPE) then
DotazNaUkonceni;
end;
function TformOOPPohyb.MamNarokNaPolozku(var outMsg: string): Boolean;
var lSQL, msg: string;
poslVyd: TDateTime;
duvod, zivotnostTxt: string;
b: boolean;
rozdilDnu, zivotnostDnu: integer;
begin
result:= false;
outMsg:= '';
stredisko:= edtStredisko.Text;
stredOld:= edtStrediskoOld.Text;
if (idPolozka=0) then
outMsg:= 'Nelze identifikovat ID položky'
else
if (cisZam=0) then
outMsg:= 'Není identifikován zaměstnanec'
else
begin
lSQL:= 'SELECT TOP(1) Datum FROM ' + tblOOPPohyby + ' WHERE IDPolozky=' + idPolozka.ToString + ' AND CisloZam=' + cisZam.ToString + ' ORDER BY Datum DESC';
poslVyd:= helUtils.getHeliosDateTimeVal(Helios, 0, lSQL); // default 31.12.1899 = 0
lSQL:= 'SELECT 1 FROM ' + tblOOPPotrebnost + ' WHERE IDPolozky=' + idPolozka.ToString + ' AND IDProfese=' + idProf.ToString + ' AND Stredisko=N' + stredisko.QuotedString;
if (helUtils.sqlExistsTestGeneral(Helios, lSQL)) then
begin
lSQL:= 'SELECT d.Kod FROM ' + tblOOPPotrebnost + ' p INNER JOIN ' + tblOOPDuvod + ' d ON (d.ID=p.IDDuvod) WHERE p.IDPolozky=' + idPolozka.ToString
+ ' AND p.IDProfese=' + idProf.ToString + ' AND p.Stredisko=N' + stredisko.QuotedString;
duvod:= helUtils.getHeliosStrVal(Helios, '', lSQL);
if (duvod='1') then
begin
outMsg:= 'Důvod výměny - IHNED';
result:= true;
end
else
if (duvod='Z') and (1=0) then
begin
outMsg:= 'Důvod výměny - SEZÓNNÍ POLOŽKA';
result:= true;
end
else
if (duvod='2') or (duvod='Z') then
begin
outMsg:= '';
b:= false;
lSQL:= 'SELECT (ISNULL(ZivotnostMin, 0) * CONVERT(int, CASE ISNULL(ZivotnostMinDruh, N'''') WHEN N''D'' THEN 1 WHEN N''M'' THEN 31 WHEN N''R'' THEN 365 ELSE 0 END))'
+ ' AS PocetDnu FROM ' + tblOOPPotrebnost + ' WHERE IDProfese=' + idProf.ToString + ' AND IDPolozky=' + idPolozka.ToString + ' AND Stredisko=N' + stredisko.QuotedString;
zivotnostDnu:= helUtils.getHeliosIntVal(Helios, 0, lSQL);
if (poslVyd>0) then
begin
rozdilDnu:= DaysBetween(poslVyd, edtDatum.DateTime);
if (rozdilDnu<zivotnostDnu) then
begin
if (duvod='2') then
msg:= 'POLOŽKA S MINIMÁLNÍ ŽIVOTNOSTÍ';
if (duvod='Z') then
msg:= 'SEZÓNNÍ POLOŽKA S ŽIVOTNOSTÍ';
lSQL:= 'SELECT CASE WHEN ISNULL(ZivotnostMin,0)>0 THEN CONVERT(nvarchar, ZivotnostMin) + N'' '' + ISNULL(ZivotnostMinDruh, N'''') ELSE N'''' END AS ZivotnostTxt FROM '
+ tblOOPPotrebnost + ' WHERE IDProfese=' + idProf.ToString + ' AND IDPolozky=' + idPolozka.ToString + ' AND Stredisko=N' + stredisko.QuotedString;
zivotnostTxt:= helUtils.getHeliosStrVal(Helios, '', lSQL);
if (TaskDlgYesNo('POZOR', msg, 'Dříve vydaná položka ještě nedosáhla své životnosti' + IfThen(zivotnostTxt<>'', ' (' + zivotnostTxt + ')', '')
+ CRLF + 'Chcete ji přesto vydat ?', tdiWarning, tcbNo)=mrYes) then
begin
result:= true;
btnOK.Enabled:= true;
end
else
btnOK.Enabled:= false;
{
with TTaskDialog.Create(nil) do
begin
try
lSQL:= 'SELECT CASE WHEN ISNULL(ZivotnostMin,0)>0 THEN CONVERT(nvarchar, ZivotnostMin) + N'' '' + ISNULL(ZivotnostMinDruh, N'''') ELSE N'''' END AS ZivotnostTxt FROM '
+ tblOOPPotrebnost + ' WHERE IDProfese=' + idProf.ToString + ' AND IDPolozky=' + idPolozka.ToString + ' AND Stredisko=N' + stredisko.QuotedString;
zivotnostTxt:= helUtils.getHeliosStrVal(Helios, '', lSQL);
Caption:= 'POZOR';
Title:= 'NEDODRŽENA ŽIVOTNOST';
Text:= 'Dříve vydaná položka ještě nedosáhla své životnosti' + IfThen(zivotnostTxt<>'', ' (' + zivotnostTxt + ')', '') + CRLF + 'Chcete ji přesto vydat ?';
MainIcon:= tdiWarning;
DefaultButton:= tcbNo;
CommonButtons:= [tcbYes, tcbNo];
if (Execute) then
if (ModalResult=mrYes) then
begin
result:= true;
btnOK.Enabled:= true;
end
else
btnOK.Enabled:= false;
finally
Free;
end;
end;
}
end;
end
else
begin
outMsg:= 'Položka má nastavenu minimální životnost ale nebyl dohledán předešlý výdej.';
result:= true;
btnOK.Enabled:= true;
end;
end
else
begin
outMsg:= 'V tabulce Potřebnosti nebyl dohledán důvod výdeje položky';
end;
end
else
begin
outMsg:= 'Na položku nemá zaměstnanec právo, není zadána Potřebnost';
idPolozka:= 0;
polozka:= '';
polozkaNum:= '';
edtPolozka.Text:= '';
edtPolozkaText.Text:= '';
if (edtPolozka.CanFocus) then
edtPolozka.SetFocus;
end;
end;
end;
procedure TformOOPPohyb.edtPolozkaButtonClick(Sender: TObject);
var podm: string;
begin
podm:= 'hvw_TabOOP_Polozky.ID IN (SELECT IDPolozky FROM ' + tblOOPPotrebnost + ' WHERE (StrediskoOld=N' + edtStrediskoOld.Text.QuotedString + ' OR Stredisko=N' + edtStredisko.Text.QuotedString
+ ') AND IDProfese=' + idProf.ToString + ')';
if (bidOOPPolozky>0) then
if Helios.Prenos2(bidOOPPolozky, 'hvw_TabOOP_Polozky.ID', 'hvw_TabOOP_Polozky.Cislo', oVar1, oVar2, podm, 'Položka', false, true, false, 1) then
begin
idPolozka:= oVar1;
polozkaNum:= VarToStr(oVar2);
edtPolozka.Text:= polozkaNum;
if (LeftStr(polozkaNum,2)='N''') and (RightStr(polozkaNum,1)='''') then
begin
polozkaNum:= polozkaNum.Substring(2, 255);
polozkaNum:= polozkaNum.Substring(0, Length(polozkaNum)-1);
end;
edtPolozkaExit(Sender);
end;
end;
procedure TformOOPPohyb.edtPolozkaEnter(Sender: TObject);
begin
infoUkazano:= false;
end;
procedure TformOOPPohyb.edtPolozkaExit(Sender: TObject);
begin
edtPolozka.Text:= edtPolozka.Text.Trim;
if (edtPolozka.Text<>'') then
begin
if not(TryStrToInt(edtPolozka.Text, idPolozka)) then
idPolozka:= 0;
edtPolozkaText.Text:= helUtils.getHeliosStrVal(Helios, '', 'SELECT Nazev FROM ' + tblOOPPolozky + ' WHERE ID=' + idPolozka.ToString);
polozkaNum:= helUtils.getHeliosStrVal(Helios, '', 'SELECT Cislo FROM ' + tblOOPPolozky + ' WHERE ID=' + idPolozka.ToString);
polozka:= edtPolozkaText.Text;
if not(MamNarokNaPolozku(outMsg)) then
begin
btnOK.Enabled:= false;
edtPolozka.Text:= '';
edtPolozkaText.Text:= '';
idPolozka:= 0;
polozka:= '';
if (outMsg<>'') and not(infoUkazano) then
begin
TaskDlgOK('POZOR', 'CHYBA', outMsg, tdiWarning);
infoUkazano:= true;
outMsg:= '';
end;
end
else
begin
btnOK.Enabled:= true;
if (outMsg<>'') and not(infoUkazano) then
begin
TaskDlgOK('POZOR', 'INFORMACE', outMsg, tdiWarning);
infoUkazano:= true;
outMsg:= '';
end;
end;
end;
end;
procedure TformOOPPohyb.edtPrijmJmButtonClick(Sender: TObject);
var c: integer;
begin
if Helios.Prenos2(bidCisZam, 'TabCisZam.Cislo', 'TabCisZam.PrijmeniJmeno', oVar1, oVar2, '', 'Zaměstnanec', false, true, false, 1) then
begin
cisZam:= oVar1;
edtOsCislo.Text:= cisZam.ToString;
if not(TryStrToInt(edtOsCislo.Text, c)) then
c:= 0;
cisZam:= c;
if (NactiUdajeZamestnance(cisZam)) then
if (edtProfese.CanFocus) then
edtProfese.SetFocus;
end;
end;
procedure TformOOPPohyb.edtProfeseButtonClick(Sender: TObject);
var lSQL, podm: string;
c: integer;
begin
podm:= 'hvw_TabOOP_Profese.StrediskoOld=N' + stredOld.QuotedString;
if (bidOOPProfese>0) then
if Helios.Prenos2(bidOOPProfese, 'hvw_TabOOP_Profese.ID', 'hvw_TabOOP_Profese.Profese', oVar1, oVar2, podm, 'Profese', false, true, false, 1) then
begin
if not(TryStrToInt(VarToStr(oVar1), c)) then
c:= 0;
idProf:= c;
// pokud existuje ext.sloupec, profesi uloz
if (idZam>0) and (helUtils.sqlExistsTestGeneral(Helios, 'SELECT 1 FROM (VALUES(1)) t1(col1) WHERE COL_LENGTH(N' + tblCisZamE.QuotedString + ', N''_OOP_Profese'') IS NOT NULL')) then
begin
lSQL:= 'UPDATE ' + tblCisZamE + ' SET _OOP_Profese=' + IfThen(idProf=0, 'NULL', idProf.ToString) + ' WHERE ID=' + idZam.ToString + CRLF;
if (idProf>0) then
lSQL:= lSQL + 'IF (@@ROWCOUNT=0) INSERT ' + tblCisZamE + ' (ID, _OOP_Profese) SELECT ' + idZam.ToString + ', ' + idProf.ToString;
Helios.ExecSQL(lSQL);
end;
profese:= VarToStr(oVar2);
if (LeftStr(profese,2)='N''') and (RightStr(profese,1)='''') then
begin
profese:= profese.Substring(2, 255);
profese:= profese.Substring(0, Length(profese)-1);
end;
edtProfese.Text:= profese;
if (edtDatum.CanFocus) then
edtDatum.SetFocus;
end;
end;
procedure TformOOPPohyb.edtStrediskoButtonClick(Sender: TObject);
begin
if (Helios.Prenos(bidCisZam, 'TabCisZam.Cislo', oVar1, '', 'Zaměstnanec', true)) then
begin
stredisko:= VarToStr(oVar1);
edtStredisko.Text:= stredisko;
edtStrediskoText.Text:= helUtils.getHeliosStrVal(Helios, '', 'SELECT Nazev FROM ' + tblStrom + ' WHERE Cislo=N' + edtStredisko.Text.QuotedString);
stredOld:= helUtils.getHeliosStrVal(Helios, '', 'SELECT TOP(1) StrediskoOld FROM ' + tblOOPProfese + ' WHERE Stredisko=N' + edtStredisko.Text.QuotedString);
edtStrediskoOld.Text:= stredOld;
end;
end;
procedure TformOOPPohyb.FormShow(Sender: TObject);
begin
bidOOPProfese:= helUtils.getHeliosIntVal(Helios, 0, 'SELECT DPBID FROM ' + tblObecPrehled + ' WHERE NazevSys=N''hvw_TabOOP_Profese''');
bidOOPPolozky:= helUtils.getHeliosIntVal(Helios, 0, 'SELECT DPBID FROM ' + tblObecPrehled + ' WHERE NazevSys=N''hvw_TabOOP_Polozky''');
edtDatum.DateTime:= Now;
strediskoUser:= helUtils.getHeliosStrVal(Helios, '', 'SELECT z.Stredisko FROM ' + tblCisZam + ' z INNER JOIN ' + tblUserCfg + ' u ON (u.LoginName=z.LoginId) WHERE u.LoginName=SUSER_SNAME()');
idZamUser:= helUtils.getHeliosIntVal(Helios, 0, 'SELECT ID FROM ' + tblCisZam + ' WHERE LoginId=SUSER_SNAME()');
superUserOOP:= false;
if (idZamUser>0) and (helUtils.sqlExistsTestGeneral(Helios, 'SELECT 1 FROM (VALUES(1)) t1(col1) WHERE COL_LENGTH(N' + tblCisZamE.QuotedString + ', N''_OOP_SuperUser'') IS NOT NULL')) then
superUserOOP:= helUtils.getHeliosBoolVal(Helios, false, 'SELECT CONVERT(bit, ISNULL(_OOP_SuperUser, 0)) FROM ' + tblCisZamE + ' WHERE ID=' + idZamUser.ToString);
if (jeTest) then
superUserOOP:= jeTest;
end;
end.