<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="CSEasyListImport.aspx.vb" Inherits="CSEasyLists.CSEasyListImport" %>
<%@ register tagprefix="ex" namespace="Exact.Web.UI.Controls" assembly="Exact.Web.UI.Controls" %>

<html>
<head>
    <title></title>
    <link runat="server" id="ExactCSS" href="Exact.css" type="text/css" rel="stylesheet" />
    <script language="javascript" type="text/javascript" src="jquery.js"></script>
    <script language="javascript" type="text/javascript">
        function ImportFiles() {
            $("#btnDisplay").attr("disabled", "disabled");
            SysSubmit();
        }

        function ConfirmImport() {
            if (controleerUseConnectionSelects())
                SysSubmit(1);
            else
                SysConfirm(5, 0, 'U dient een connectie te kiezen voor alle te importeren definities.');
        }

        function controleerUseConnectionSelects() {
            const rows = document.querySelectorAll("#lvConfirm_Header tr.DataLight, #lvConfirm_Header tr.DataDark");

            for (let i = 0; i < rows.length; i++) {
                const checkbox = rows[i].querySelector("input[name='lvConfirm$cCheck']");
                const select = rows[i].querySelector("select[id^='UseConn']");

                if (checkbox && checkbox.checked) {
                    if (select && !select.value) {
                        return false;
                    }
                }
            }

            return true;
        }

    </script>
</head>
<body>
<ep:form id="Baco" runat="server" enctype="multipart/form-data">

<ex:CardControl runat="server" ID="Card" Action="Show">
    <ex:header id="hdr" caption="Easy Lists" captionid="0" CaptionSuffix=":Import" CaptionSuffixID="7440" runat="server" showsitemappath="false">
        <ex:headerbutton id="hbFavorite" buttonstyle="Favorite" />
    </ex:header>

    <ex:buttonbar runat="server" id="Buttons">
        <ex:button runat="server" id="btnDisplay" buttonstyle="Custom" Caption="Display" CaptionID="8549" onClick="ImportFiles();" />
        <ex:button runat="server" id="btnImport" buttonstyle="Custom" Caption="Import" CaptionID="7440" onClick="ConfirmImport();" />
        <ex:button runat="server" id="btnClose" buttonstyle="Close" />
    </ex:buttonbar>

    <ex:bcerrormessages runat="server" id="errmsg" Mode="Notification" />

    <ex:cardrow runat="server" id="crImport">
        <ex:cardcolumn runat="server" id="ccImport">
		    <ex:cardsection runat="server" id="csImport" caption="Import" captionid="7440" DefaultVisible="True">
				<ex:cardfield runat="server" id="cfFile" caption="Easy Lists export file" captionid="0">
                    <input runat="server" id="FileAttachment" type="file" size="100" />
				</ex:cardfield>
            </ex:cardsection>

            <ex:cardsection runat="server" id="csApprove" caption="Immediate validation" captionid="33311" DefaultVisible="True">
				<ex:cardfield runat="server" id="cfApprove" caption="Immediate validation" captionid="33311" CaptionSuffix=":Requests" CaptionSuffixID="17">
                    <ex:checkbox runat="server" id="chkApprove" />
				</ex:cardfield>
            </ex:cardsection>

            <ex:cardlistview runat="server" id="clvConfirm" caption="Confirm" captionid="6593" captionsuffix=":Import" captionsuffixid="7440" showheader="False" customizecolumns="False" customizerows="False">
                <ex:listview runat="server" id="lvConfirm" ongetdata="lvConfirm_OnGetData" showbutton="False" visible="True" caption="Confirm" captionid="6593" captionsuffix=":Import" captionsuffixid="7440" ShowPageSize="false" ScrollBar="None">
                    <Columns>
                        <ex:listviewcheckboxcolumn runat="server" id="cCheck" type="selectall" selectallprefix="chk" align="Center" width="5%" />
                        <ex:listviewcolumn id="colTitle" caption="Title" captionid="10189" sorting="none"/>
                        <ex:listviewcolumn id="colConnectionUsed" caption="Connection" captionid="27055" captionsuffix=":In use" captionsuffixid="6385" width="10%" sorting="none"/>
                        <ex:listviewcolumn id="colConnectionImport" caption="Connection" captionid="27055" captionsuffix=":Import" captionsuffixid="7440" width="10%" sorting="none"/>
                        <ex:listviewcolumn id="colExists" caption="Existing" captionid="22" sorting="none" width="5%"/>
                    </Columns>
                </ex:listview>
            </ex:cardlistview>
        </ex:cardcolumn>
    </ex:cardrow>
</ex:CardControl>
</ep:form>
</body>
</html>
