Attribute VB_Name = "Log"
Option Explicit


'----------------------------------------------------------
'zapis do logu
'----------------------------------------------------------

Public Sub ZapisDoLoguT()

    Dim sTmp1$
    Dim i As Integer
    
    sTmp1 = Space$(512)
    GetUserName sTmp1, Len(sTmp1)
    User = Trim$(sTmp1)
        
    IP = Form1.IPSensor.LocalIP

    Open PomNazev For Append As #11
        
        Print #11, "---------------------------------------------------------------------------------------"
        Print #11, "CAS: " & CStr(Time)
        Print #11, "IP ADRESA: " & IP
        Print #11, "Windows USER: " & User
        Print #11, "UZIVATEL: "; AktJmeno
        Print #11, "ZMENA: "
        
        For i = 0 To ZmenaIndx - 1
            Print #11, "   " & ZmenaLog(i)
        Next i
        
        Print #11, vbCrLf
        
    Close #11

End Sub


'----------------------------------------------------------
'zapis zmeny denniho textu do logu
'----------------------------------------------------------

Public Sub LogEdit()

    Dim i As Integer
    Dim h As Integer
    Dim m As Integer
    
    For i = 0 To ZmenaIndx - 1
        ZmenaLog(i) = ""
    Next i
    
    ZmenaIndx = 0
        
    If (DenNeboNahr = "D") Then
        PomNazev = CestaSoubory & "/RDS-logy/UPravovano/Texty/" & GenerujNazevSouboru(EDatum) & "log.rds"
    ElseIf (DenNeboNahr = "N") Then
        PomNazev = CestaSoubory & "/RDS-logy/UPravovano/Texty/" & "NahradniTextlog.rds"
    Else
        PomNazev = CestaSoubory & "/RDS-logy/UPravovano/Texty/" & DenNeboNahr & "log.rds"
    End If
    
    If (Dir(PomNazev) <> "") Then
        
        For i = 0 To 1439
                
           If (CelyText(i, 1) <> CelyTextZ(i, 1)) Then
                h = i \ 60
                m = i Mod 60
                ZmenaLog(ZmenaIndx) = Prevod(h) & ":" & Prevod(m) & "    " & CelyTextZ(i, 1)
                CelyText(i, 1) = CelyTextZ(i, 1)
                ZmenaIndx = ZmenaIndx + 1
           End If
           
        Next i
            
    Else:
                
        For i = 0 To 1439
            h = i \ 60
            m = i Mod 60
            ZmenaLog(ZmenaIndx) = Prevod(h) & ":" & Prevod(m) & "    " & CelyTextZ(i, 1)
            CelyText(i, 1) = CelyTextZ(i, 1)
            ZmenaIndx = ZmenaIndx + 1
        Next i
    
    End If
    
    If (ZmenaIndx > 0) Then
        ZapisDoLoguT
    End If

End Sub


'----------------------------------------------------------
'zapis zmeny proma do logu
'----------------------------------------------------------

Public Sub LogPromo(ind As Integer, s As String)

    Dim i As Integer
    Dim h As Integer
    Dim m As Integer
    Dim casy As String
    Dim dny As String
    Dim sTmp1$
    
    sTmp1 = Space$(512)
    GetUserName sTmp1, Len(sTmp1)
    User = Trim$(sTmp1)
        
    IP = Form1.IPSensor.LocalIP
    
    casy = ""
    dny = ""
        
    Open CestaSoubory & "/RDS-logy/Upravovano/Promo/Promo" & ind + 1 & "log.rds" For Append As #12
    
    Print #12, "---------------------------------------------------------------------------------------"
    Print #12, "CAS: " & CStr(Time)
    Print #12, "IP ADRESA: " & IP
    Print #12, "Windows USER: " & User
    Print #12, "UZIVATEL: "; AktJmeno
    
    If (s <> "del") Then
    
        Print #12, "   " & "Poznamka: " & PromoPozn(ind)
        Print #12, "   " & "Text Proma: " & PromoText(ind)
        Print #12, "   " & "Vysilano od: " & Mid(PromoDatum(ind, 1), 1, 2) & "." & Mid(PromoDatum(ind, 1), 3, 2) & "." & Mid(PromoDatum(ind, 1), 5, 4)
        Print #12, "   " & "Vysilano do: " & Mid(PromoDatum(ind, 2), 1, 2) & "." & Mid(PromoDatum(ind, 2), 3, 2) & "." & Mid(PromoDatum(ind, 2), 5, 4)
        
        If (Form1.ChckProPo(ind).Value = 1) Then
            dny = "po,"
        End If
        If (Form1.ChckProUt(ind).Value = 1) Then
            dny = dny & "ut,"
        End If
        If (Form1.ChckProSt(ind).Value = 1) Then
            dny = dny & "st,"
        End If
        If (Form1.ChckProCt(ind).Value = 1) Then
            dny = dny & "ct,"
        End If
        If (Form1.ChckProPa(ind).Value = 1) Then
            dny = dny & "pa,"
        End If
        If (Form1.ChckProSo(ind).Value = 1) Then
            dny = dny & "so,"
        End If
        If (Form1.ChckProNe(ind).Value = 1) Then
            dny = dny & "ne"
        End If
    
        Print #12, "   " & "Vysilaci dny: " & dny
        
        For i = 1 To Form1.LstPromoCasy(ind).ListCount
            casy = casy & PromoCas(i, (ind)) & ","
        Next i
        
        Print #12, "   " & "Vysilaci casy: " & casy
    
    Else
            
        Print #12, "   " & "PROMO BYLO SMAZANO"
        
    End If
        
    Close #12

End Sub
