Public Class Lide_seznam
    Inherits System.Web.UI.UserControl

    Public sAdresaUpravit As String = gadrLide_upravit
    Public sAdresaOdstranit As String = gadrLide_odstranit
    Public sAdresaSave As String = gadrLide_seznam

    Public sTable As String = "[kontakt].[lide]"

    Public bShowLocalization As Boolean = True

    ''' <summary>
    ''' Seznam zaznamu.
    ''' Verze: 1.0
    ''' Tabulka musi obsahovat pole - id, sort
    ''' </summary>
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        NacistZaznamy()

        cmdNovy.Attributes.Add("onclick", "ShowPopInfo('" & gstrProbihaNacitaniStranky & "');")

        Dim pSort As New PCSolution.SortItems
        pSort.InsertSorting(sTable)

    End Sub

#Region "  NACIST ZAZNAMY  "

    Sub NacistZaznamy()

        Dim s As String = ""

        Dim DS As DataTable = DB.ExecuteSelectCommand("SELECT * FROM " & sTable & " ORDER BY sort")

        For Each cRow As DataRow In DS.Rows

            s &= "<tr id=""sort" & cRow("id") & """>"

            If cRow("typ") = 0 Then 'Kontakt

                s &= "<td class=""item-edit first""><a href=""/id-" & cRow("id") & sAdresaUpravit & """>Upravit</a></td>"
                s &= "<td class=""item-edit""><a href=""#"" onclick=""ConfirmDelete('Odstranit kontakt', 'Opravdu chcete odstranit kontakt?','/id-" & cRow("id") & sAdresaOdstranit & "','','');return false;"">Odstranit</a></td>"

                s &= "<td class=""pointer"">"
                If cRow("zobrazit" & _Language) = "False" Then s &= "<span class=""label label-red""> </span>&nbsp;"

                If cRow("jmeno" & _Language) = "" Then cRow("jmeno" & _Language) = "<span class=""lokalizace-empty"">" & cRow("jmenocz") & "</span>"

                If cRow("titul1" & _Language) <> "" Then s &= cRow("titul1" & _Language) & " "
                s &= cRow("jmeno" & _Language)
                If cRow("titul2" & _Language) <> "" Then s &= " " & cRow("titul2" & _Language)
                s &= "</td>"

                s &= "<td class=""pointer""><a href=""mailto://" & cRow("email") & """>" & cRow("email") & "</a></td>"
                s &= "<td class=""pointer"">" & cRow("telefon") & "</td>"
                s &= "<td class=""pointer"">" & cRow("mobil") & "</td>"
                s &= "<td class=""pointer"">Kontakt</td>"

            ElseIf cRow("typ") = 1 Then 'Nadpis

                s &= "<td class=""item-edit first""><a href=""/id-" & cRow("id") & gadrLide_nadpis_upravit & """>Upravit</a></td>"
                s &= "<td class=""item-edit""><a href=""#"" onclick=""ConfirmDelete('Odstranit nadpis', 'Opravdu chcete odstranit nadpis?','/id-" & cRow("id") & sAdresaOdstranit & "','','');return false;"">Odstranit</a></td>"

                s &= "<td class=""pointer"">"
                If cRow("zobrazit" & _Language) = "False" Then s &= "<span class=""label label-red""> </span>&nbsp;"

                If cRow("nadpis" & _Language) = "" Then cRow("nadpis" & _Language) = "<span class=""lokalizace-empty"">" & cRow("nadpiscz") & "</span>"
                s &= cRow("nadpis" & _Language) & "</td>"
                s &= "<td class=""pointer"" colspan=""3""></td>"
                s &= "<td class=""pointer"">Nadpis</td>"

            ElseIf cRow("typ") = 2 Then 'Podnadpis

                s &= "<td class=""item-edit first""><a href=""/id-" & cRow("id") & gadrLide_podnadpis_upravit & """>Upravit</a></td>"
                s &= "<td class=""item-edit""><a href=""#"" onclick=""ConfirmDelete('Odstranit podnadpis', 'Opravdu chcete odstranit podnadpis?','/id-" & cRow("id") & sAdresaOdstranit & "','','');return false;"">Odstranit</a></td>"

                s &= "<td class=""pointer"">"
                If cRow("zobrazit" & _Language) = "False" Then s &= "<span class=""label label-red""> </span>&nbsp;"

                If cRow("podnadpis" & _Language) = "" Then cRow("podnadpis" & _Language) = "<span class=""lokalizace-empty"">" & cRow("podnadpiscz") & "</span>"
                s &= cRow("podnadpis" & _Language) & "</td>"
                s &= "<td class=""pointer"" colspan=""3""></td>"
                s &= "<td class=""pointer"">Podnadpis</td>"

            End If

            s &= "</tr>"

        Next

        ph.Controls.Add(New LiteralControl(s)) : s = ""

        If DS.Rows.Count = 0 Then
            phTable.Visible = False
            phNoItem.Controls.Add(New LiteralControl("<div class=""noitem"">Není nalezený žádný kontakt.</div>"))
        End If

    End Sub

    Private Sub cmdNovy_Click(sender As Object, e As EventArgs) Handles cmdNovy.Click

        Response.Redirect(sAdresaUpravit)

    End Sub

    Private Sub cmdNovy_nadpis_Click(sender As Object, e As EventArgs) Handles cmdNovy_nadpis.Click

        Response.Redirect(gadrLide_nadpis_upravit)

    End Sub

    Private Sub cmdNovy_podnadpis_Click(sender As Object, e As EventArgs) Handles cmdNovy_podnadpis.Click

        Response.Redirect(gadrLide_podnadpis_upravit)

    End Sub

#End Region


End Class