﻿<html><head><meta charset="utf-8"></head><body>﻿
    <title>IOTAP Report Scheduler : Configuration Page</title>
    <script src="../../../ClientGlobalContext.js.aspx" type="text/javascript"></script>
    <script src="Scripts/jquery1.8.3.js" type="text/javascript"></script>
    <script src="Scripts/Json.js" type="text/javascript"></script>
    <script language= "jscript" type="text/jscript">

        // Global variables
        var context;
        var serverUrl;
        var selEmailUser;
        var setemailuser;
        var setemailuserid;
        var success = true;
        var allEntityListArray = new Array();
        var entityArray = new Array();

        var currUserLcid = Xrm.Page.context.getUserLcid();

        window.onload = function () {
            RetrieveHtmlTemplates();
            setTimeout( function() {
                 RetrieveEmailBodyCustomization();
                RetrieveAllEntities();
            }, 1000 );
            
        }

        function sortMultiDimensional(a, b) {
                                                  // Namrata
            entityArray.sort(function (a, b) {
                var aName = a[0].toLowerCase();
                var bName = b[0].toLowerCase();
                return ((aName < bName) ? -1 : ((aName > bName) ? 1 : 0));
            })
        }

        var GetServerURL = function () {
            return Xrm.Page.context.getClientUrl();            
        };
        
        var RetrieveAllEntities = function () {

            var counter = 0;

            $.ajax({
                type: "GET",
                contentType: "application/json; charset=utf-8",
                datatype: "json",
                url: GetServerURL() + "/api/data/v8.0/EntityDefinitions?$select=SchemaName,LogicalName,DisplayName,PrimaryNameAttribute,MetadataId&$filter=IsCustomizable/Value eq true",

                beforeSend: function (XMLHttpRequest) {
                                 
                    XMLHttpRequest.setRequestHeader("Accept", "application/json");
                    XMLHttpRequest.setRequestHeader("OData-MaxVersion", "4.0");
                    XMLHttpRequest.setRequestHeader("OData-Version", "4.0");

                },
            success: function (data, textStatus, XmlHttpRequest) {

                if (data.value != null & data.value.length > 0) {
                    for (var i = 0; i < data.value.length; i++)

                    {
                        entityArray[i] = new Array(2);
                        entityArray[i][0] = data.value[i].LogicalName;
                        if ( data.value[i].DisplayName.UserLocalizedLabel )
                            entityArray[i][1] = data.value[i].DisplayName.UserLocalizedLabel.Label;
                        else
                        {
                            var labelColl = data.value[i].DisplayName.LocalizedLabels;
                            for ( var key in labelColl ) {
                                if ( labelColl.hasOwnProperty( key ) ) {
                                    if ( labelColl[key].LanguageCode == currUserLcid ) {
                                        entityArray[i][1] = labelColl[key].Label;                                        
                                    }
                                }
                            }
                        }
                     counter++;
                    }                   
                }
                 
                entityArray.sort( function ( a, b )
                {
                    var textA = a[1];
                    var textB = b[1];
                    return ( textA < textB ) ? -1 : ( textA > textB ) ? 1 : 0;
                } );


                for ( var i = 0; i < counter; i++ ) {
                    //alert( entityArray[i][0] + "   " + entityArray[i][1] )
                    $('#entityList').append('<option value="' + entityArray[i][0] + '">' + entityArray[i][1] + '</option>')
                }                
   
            },

            error: function (XmlHttpRequest, textStatus, errorThrown) {
                alert("error" + textStatus + errorThrown);
               
            }
                
        });
            serverUrl = GetServerURL();

            ODATA_ENDPOINT = serverUrl + "/api/data/v8.0/" + "iotap_schedulereportselectedentitieses";


            RetrieveEntityList(ODATA_ENDPOINT, false);
        };
       
        var RetrieveHtmlTemplates = function (odataSetName) {
            $.ajax({
                type: "GET",
                contentType: "application/json; charset=utf-8",
                datatype: "json",
                url: GetServerURL() + "/api/data/v8.0/" + "iotap_htmltemplateses?$select=iotap_htmltemplatesid,iotap_name", //Namrata
                beforeSend: function (XMLHttpRequest) {
                    //Specifying this header ensures that the results will be returned as JSON.             
                    XMLHttpRequest.setRequestHeader("Accept", "application/json");
                    XMLHttpRequest.setRequestHeader("OData-MaxVersion", "4.0");
                    XMLHttpRequest.setRequestHeader("OData-Version", "4.0");

                },
                
                success: function (data, textStatus, XmlHttpRequest) {
                    if ( data.value != null & data.value.length > 0 ) {                        
                        $( data.value ).each( function ( i, data )
                        {  
                            $("#drpHtmltemplates").append('<option value="' + $(this)[0].iotap_htmltemplatesid + '">' + $(this)[0].iotap_name + '</option>');
                        });
                    }
                },

                error: function (XmlHttpRequest, textStatus, errorThrown) {
                    alert(JSON.parse(XmlHttpRequest.responseText).error.message.value);
                }
            });
        };

        var RetrieveEmailBodyCustomization = function (odataSetName) {
            $.ajax({
                type: "GET",
                contentType: "application/json; charset=utf-8",
                datatype: "json",
                url: GetServerURL() + "/api/data/v8.0/iotap_emailbodycustomizations",   //Namrata
                beforeSend: function (XMLHttpRequest) {
                    //Specifying this header ensures that the results will be returned as JSON.             
                    XMLHttpRequest.setRequestHeader("Accept", "application/json");
                    XMLHttpRequest.setRequestHeader("OData-MaxVersion", "4.0");
                    XMLHttpRequest.setRequestHeader( "OData-Version", "4.0" );                   
                },
                
                success: function (data, textStatus, XmlHttpRequest) {
                    if ( data.value != null & data.value.length > 0 ) {                        
                        $( "#drpHtmltemplates" ).val( data.value[0]._iotap_templateid_value );
                        $("#txtIotap_emailbodycustomizationid").val(data.value[0].iotap_emailbodycustomizationid);
                        $("#txtExcludeDomains").val(data.value[0].iotap_excludedomains);
                        $("#txtExcludeUsers").val(data.value[0].iotap_excludeusers);
                    }
                },

                error: function (XmlHttpRequest, textStatus, errorThrown) {
                    alert(JSON.parse(XmlHttpRequest.responseText).error.message.value);
                }
            });
        };

        var errorRetrieveEntities = function (error) {

        };
                
        function errorHandler(XmlHttpRequest) {
            ///<summary>
            /// Helper function to handle any errors when using the REST endpoint.
            ///</summary
            var errorMessage = "";
            try {
                errorMessage = JSON.parse(XmlHttpRequest.responseText).error.message.value;
            }
            catch (e) {
                errorMessage = "Unable to parse Error message."
            }
            showMessage("Error : " +
        XmlHttpRequest.status + ": " +
        XmlHttpRequest.statusText + ": " +
        errorMessage, "errormsg");
        }

        var LoadSelectedEntityList = function (data, successCallback, errorCallback) {
            var entityArray = [data.length];
            var counter = 0;
            for ( var i = 0; i < data.length; i++ ) {

                entityArray[i] = new Array(2);
                entityArray[i][0] = data[i].iotap_entitylogicalname;
                entityArray[i][1] = data[i].iotap_entityname;
                counter++;
            }
            
            //entityArray.sort( sortMultiDimensional );

            for (var i = 0; i < counter; i++) {
                $('#selectedEntityList').append('<option value="' + entityArray[i][0].toLowerCase() + '">' + entityArray[i][1].toString() + '</option>')
                $("#entityList option[value='" + data[i].iotap_entitylogicalname + "']").remove();
                setemailuser = data[i]["_iotap_emailuser_value@OData.Community.Display.V1.FormattedValue"]; //Namrata
                setemailuserid = data[i]._iotap_emailuser_value

                if (data[i]._iotap_emailuser_value != null) {                 //--Namrata
                    document.getElementById("userName").value = setemailuser;
                    document.getElementById("userId").value = setemailuserid;
                }
              
                $("#eventlog").attr('checked', data[i].iotap_eventlog);
                
            }
            
        };
        function ToLeft() {
            for (var i = 0; i < selectedEntityList.length; i++) {
                if (selectedEntityList[i].selected) {
                    var optionObj = document.createElement("OPTION");
                    optionObj.text = selectedEntityList[i].text;
                    optionObj.value = selectedEntityList[i].value;
                    entityList.options.add(optionObj);

                    selectedEntityList.remove(i);
                }
            }
        }

        function ToRight() {
            for (var i = 0; i < entityList.length; i++) {
                if (entityList[i].selected) {
                    var optionObj = document.createElement("OPTION");
                    optionObj.text = entityList[i].text;
                    optionObj.value = entityList[i].value;
                    selectedEntityList.options.add(optionObj);

                    entityList.remove(i);
                }
            }
        };


        function StartProcess() {
            ClearMessage();
            if (success == true) {
                $('#loadingmessage').show();
                setTimeout(function () { SaveSelectedEntityList() }, 1000);
            }
        }

        function SaveSelectedEntityList() {
            var excludedDomains = validateMultipleCommaSeparated($("#txtExcludeDomains"), ';');
            var excludedUserEmailIds = validateMultipleCommaSeparated($("#txtExcludeUsers"), ';');

            if (!excludedDomains) {
                alert('Please correct Domain names.')
                $('#loadingmessage').hide();
                return;
            } else if (!excludedUserEmailIds) {
                alert('Please correct User Email Ids.')
                $('#loadingmessage').hide();
                return;
            }

            // clear all retrieved entity names during page load
            allEntityListArray.length = 0;
            // Retrieve all entity names & delete all
            //RetrieveEntityList(serverUrl + ODATA_ENDPOINT, true); --- Namrata
            RetrieveEntityList(ODATA_ENDPOINT, true);
            
            // clear all previous saved entity names.
            allEntityListArray.length = 0;

           
            //yo
            var eventlog = $("#eventlog").is(":checked");
            //yo
            // Enable multiple emails to multiple user test functionality if checkbox is checked. This will create all emails in draft mode.
            //var chkTestEmails = $("#chkTestEmails").is(":checked");

            for (var i = 0; i < selectedEntityList.length; i++) {
                var objCampaign = {};
                objCampaign.iotap_entityname = selectedEntityList[i].text;
                objCampaign.iotap_entitylogicalname = selectedEntityList[i].value;
                objCampaign["iotap_emailuser@odata.bind"] = "/systemusers(" + document.getElementById("userId").value + ")";  //Namrata
                
                objCampaign.iotap_eventlog = eventlog;
                createRecord(objCampaign, "iotap_schedulereportselectedentitieses", null, null);  //Namrata
            }

            // Save Email Body Customization,Excluded domains,users
            SaveEmailCustomization();

            if (success == true) {               
                $( '#loadingmessage' ).hide();
                alert( "Configuration saved sucessfully" );
                window.close();
            }
        };

        function SaveEmailCustomization() {

            success = false;
            
            var objEmailBodyCustomizationCreate = {};            
            if ( $( "#drpHtmltemplates" ).val() != "" )
                objEmailBodyCustomizationCreate["iotap_templateid@odata.bind"] = "/iotap_htmltemplateses(" + $( "#drpHtmltemplates" ).val() + ")";            
            objEmailBodyCustomizationCreate.iotap_excludedomains = $("#txtExcludeDomains").val();
            objEmailBodyCustomizationCreate.iotap_excludeusers = $("#txtExcludeUsers").val();

            var objEmailBodyCustomizationUpdate = {};            
            if ($("#drpHtmltemplates").val() != "")
                objEmailBodyCustomizationUpdate["iotap_templateid@odata.bind"] = "/iotap_htmltemplateses(" + $( "#drpHtmltemplates" ).val() + ")";            
            objEmailBodyCustomizationUpdate.iotap_excludedomains = $("#txtExcludeDomains").val();
            objEmailBodyCustomizationUpdate.iotap_excludeusers = $("#txtExcludeUsers").val();

            var url = GetServerURL() + "/api/data/v8.0/iotap_emailbodycustomizations";
            var action = $( "#txtIotap_emailbodycustomizationid" ).val() != "" ? "PATCH" : "POST";
            var jsonEntity = $("#txtIotap_emailbodycustomizationid").val() != "" ? window.JSON.stringify(objEmailBodyCustomizationUpdate) : window.JSON.stringify(objEmailBodyCustomizationCreate);
            var uri = $( "#txtIotap_emailbodycustomizationid" ).val() != "" ? url + "(" + $( "#txtIotap_emailbodycustomizationid" ).val() + ")" : url

            var xhr = new XMLHttpRequest();
            xhr.open( action, uri, false );
            xhr.setRequestHeader( "Accept", "application/json" );
            xhr.setRequestHeader( "Content-Type", "application/json; charset=utf-8" );
            xhr.setRequestHeader( "OData-MaxVersion", "4.0" );
            xhr.setRequestHeader( "OData-Version", "4.0" );
            xhr.send( jsonEntity );
            
            if ( xhr.status === 200 ) {                        
                var emailBodyCustomizationUri =  xhr.getResponseHeader( "OData-EntityId" );
                var ID = emailBodyCustomizationUri.substr( emailBodyCustomizationUri.length - 38 ).substring( 1, 37 );
                $( "#txtIotap_emailbodycustomizationid" ).val( ID );
                
            }

            //clear template id field
            if ( $( "#txtIotap_emailbodycustomizationid" ).val() != "" && $( "#drpHtmltemplates" ).val() == "" ) {
                var cleartTemplateXhr = new XMLHttpRequest();
                cleartTemplateXhr.open( "DELETE", url + "(" + $( "#txtIotap_emailbodycustomizationid" ).val() + ")/iotap_templateid/$ref", false );
                cleartTemplateXhr.setRequestHeader( "Accept", "application/json" );
                cleartTemplateXhr.setRequestHeader( "Content-Type", "application/json; charset=utf-8" );
                cleartTemplateXhr.setRequestHeader( "OData-MaxVersion", "4.0" );
                cleartTemplateXhr.setRequestHeader( "OData-Version", "4.0" );
                cleartTemplateXhr.send( null );
            }

            success = true;

        }

        function validateEmail(field) {
            var regex = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,5}$/;
            return (regex.test(field)) ? true : false;
        }
        function CheckIsValidDomain(domain) {
            var re = new RegExp(/^((?:(?:(?:\w[\.\-\+]?)*)\w)+)((?:(?:(?:\w[\.\-\+]?){0,62})\w)+)\.(\w{2,6})$/);
            return domain.match(re);
        }

        function validateMultipleCommaSeparated(emailcntl, seperator) {
            var value = emailcntl.val();
            if (value != '') {
                var result = value.split(seperator);

                // If seperator is not specified in textbox like "www.google.com" without comma
                if (result.length <= 1 && (emailcntl.attr('id') == 'txtExcludeUsers' && !validateEmail(value)))
                    return false;
                else if (result.length <= 1 && (emailcntl.attr('id') == 'txtExcludeDomains' && !CheckIsValidDomain(value)))
                    return false;
                for (var i = 0; i < result.length; i++) {
                    if (result[i] != '') {
                        if (emailcntl.attr('id') == 'txtExcludeUsers' && !validateEmail(result[i])) {
                            return false;
                        } else if (emailcntl.attr('id') == 'txtExcludeDomains' && !CheckIsValidDomain(result[i])) {
                            return false;
                        }
                    }
                }
            }
            return true;
        }

        var DeleteEntityList = function (data, successCallback, errorCallback, odataSetName) {
            var jsonObject = data;
           
            for (var i = 0; i < jsonObject.length; i++) {
                $.ajax({
                    type: "DELETE",
                    contentType: "application/json; charset=utf-8",
                    datatype: "json",
                    url: odataSetName + "(" + jsonObject[i].iotap_schedulereportselectedentitiesid + ")",  //Namrata
                  
                    beforeSend: function (XMLHttpRequest) {
                        //Specifying this header ensures that the results will be returned as JSON.                 
                        XMLHttpRequest.setRequestHeader("Accept", "application/json");
                        XMLHttpRequest.setRequestHeader("OData-MaxVersion", "4.0");
                        XMLHttpRequest.setRequestHeader("OData-Version", "4.0");
                        //Specify the HTTP method DELETE to perform a delete operation.                 
                        XMLHttpRequest.setRequestHeader("X-HTTP-Method", "DELETE");
                    },
                    
                    success: function (data, textStatus, XmlHttpRequest) {
                        success = true;
                        
                    },
                    error: function (XmlHttpRequest, textStatus, errorThrown) {

                        errorHandler(XmlHttpRequest);
                    },
                    async: false
                });
            }
        };

        var RetrieveEntityList = function (odataSetName, successCallback) {
            
            $.ajax({
                type: "GET",
                contentType: "application/json; charset=utf-8",
                datatype: "json",
                url: odataSetName,
                beforeSend: function (XMLHttpRequest) {
                    //Specifying this header ensures that the results will be returned as JSON.             
                    XMLHttpRequest.setRequestHeader("Accept", "application/json");
                    XMLHttpRequest.setRequestHeader("Prefer", "odata.include-annotations=OData.Community.Display.V1.FormattedValue");

                },
                success: function (data, textStatus, XmlHttpRequest) {
                   
                    if (successCallback) {
                       
                        if (data && data.value) {
                            // Add all entity into array
                            $(data.value).each(function ()      //Namrata
                            {
                                allEntityListArray.push($(this)[0]);
                            });

                            // Delete entity
                            DeleteEntityList(allEntityListArray, null, null, odataSetName);
                        }
                        else if (data && data.value) { 
                            
                            $(data.value).each(function () {
                                allEntityListArray.push($(this)[0]);
                            });

                            DeleteEntityList(allEntityListArray, null, null, odataSetName);
                        }
                        else {
                            DeleteEntityList(data, null, null, odataSetName);
                        }
                    } else {
                       
                        if (data && data.value) {

                            $(data.value).each(function () {
                                allEntityListArray.push($(this)[0]);
                            });

                            // if selected entity list & all retrieved entities list length are not equal then add retrieved item into selectedEntityList
                            if ($("#selectedEntityList option").length != allEntityListArray.length)
                                LoadSelectedEntityList(allEntityListArray, null, null);
                        }
                        else if (data && data.value ) { 
                            // Add all entity into array
                            $(data.value).each(function () {
                                allEntityListArray.push($(this)[0]);
                            });

                            
                            // if selected entity list & all retrieved entities list length are not equal then add retrieved item into selectedEntityList
                            if ($("#selectedEntityList option").length != allEntityListArray.length)
                                LoadSelectedEntityList(allEntityListArray, null, null);
                        }
                        else {
                            LoadSelectedEntityList(data, null, null);
                        }
                    }
                },
                async: false
            });
        };

        function createRecord(entityObject, odataSetName, successCallback, errorCallback) {           

            var serverUrl = GetServerURL();    
            var ODATA_ENDPOINT = "/api/data/v8.0";  //Namrata

            //entityObject is required    
            if (!entityObject) {
                alert("entityObject is required.");
                return;
            }

            if (!odataSetName) {
                alert("odataSetName is required.");
                return;
            }

            //Parse the entity object into JSON    
            var jsonEntity = window.JSON.stringify(entityObject);
            
            //Asynchronous AJAX function to Create a CRM record using OData
            $.ajax({
                type: "POST",
                contentType: "application/json; charset=utf-8",
                datatype: "json",
                url: serverUrl + ODATA_ENDPOINT + "/" + odataSetName,
                data: jsonEntity,
                beforeSend: function (XMLHttpRequest) {
                    //Specifying this header ensures that the results will be returned as JSON.                         
                    XMLHttpRequest.setRequestHeader("Accept", "application/json");
                    XMLHttpRequest.setRequestHeader("OData-MaxVersion", "4.0");
                    XMLHttpRequest.setRequestHeader("OData-Version", "4.0");

                },
                success: function (data, textStatus, XmlHttpRequest) {
                    success = true;
                },
                error: function (XmlHttpRequest, textStatus, errorThrown) {
                   
                    errorHandler(XmlHttpRequest);

                },
                async: false
            });

        };

        function ClearMessage() {
            document.getElementById("message").innerHTML = "";
            if (document.getElementById("userName").value == "") {
                alert('Please select Email User!');
                success = false;
            }
            else if (selectedEntityList.length == 0) {
                alert('Please select atleast one entity!');
                success = false;
            }
            else {
                success = true;
            }
        }

        function showMessage(errorMessage, cssclassname) {
            document.getElementById("message").innerHTML = errorMessage;
            document.getElementById('message').className = cssclassname;
        }
        function showlookupDialog() {
         
            //Xrm.Utility.openWebResource( "iotap_CustomLookup.html", "systemuser", 650, 540 );
            window.open( "../../../iotap_CustomLookup.html", "lookup", "width=650,height=540" );
        }


        function updateNameValue(value) {
            // this gets called from the popup window and updates the field with a new value
            document.getElementById("userName").value = value;
        }

        function updateIdValue(value) {
            // this gets called from the popup window and updates the field with a new value
            document.getElementById("userId").value = value;
        }

    </script>
    <style type="text/css">        
        .label
        {
            font-family: "Segoe UI";
            font-size: 11px;
        }        
        .selectlist
        {
            font-family: "Segoe UI";
            font-size: 11px;
            width: 260px;
            height: 260px;
        }        
        .crmbutton
        {
            font-family: Segoe UI, Tahoma, Arial;
            font-size: 11px;
            height: 20px;
            padding-right: 5px;
            padding-left: 5px;
            border-top-width: 1px;
            border-right-width: 1px;
            border-bottom-width: 1px;
            border-left-width: 1px;
            border-top-style: solid;
            border-left-style: solid;
            border-bottom-style: solid;
            border-right-style: solid;
            cursor: pointer;
            background-repeat: repeat-x;
            border-bottom-color: #666666;
            border-top-color: #666666;
            border-left-color: #666666;
            border-right-color: #666666;
            background-image: url('Images/Button.png');
        }
        .errormsg
        {
            font-family: "Segoe UI";
            text-align: left;
            color: Red;
            font-size: 11px;
        }
        
        .msg
        {
            font-family: "Segoe UI";
            text-align: left;
            color: Black;
            font-size: 11px;
        }
        .loader
        {
            top: 50%;
            left: 0px;
            z-index: 99999;
            background-repeat: no-repeat;
            background-position: center;
            width: 100%;
            height: 100%;
            position: absolute;
            text-align: center;
        }
        .dropdown
        {
            font-family: Segoe UI, Tahoma, Arial;
            font-size: 11px;
            color: Black;
            ime-mode: auto;
            border: 1px solid #CCCCCC;
            margin: 1px 0 0 1px;
            width: 180px;
        }
        .ExcludeTextbox {
            width: 244px;
            font-family: Segoe UI, Tahoma, Arial;
            font-size: 11px;
            color: Black;
        }
    </style>
    <table style="width: 580px;" border="0" cellspacing="0" cellpadding="0">
        <tbody>
            <tr>
                <td class="label" colspan="2">
                    Enable Event logging
                    <img title="Set checkbox to enable detailed event logging" alt=" Set checkbox to enable detailed event logging" src="images/questionmark.jpg">
                </td>
                <td>
                    <input name="eventlog" id="eventlog" type="checkbox" value="select">
                </td>
                <td>
                </td>
            </tr>
            <tr>
                <td class="label" colspan="2">
                    Outgoing Email Owner
                    <img title="CRM User whose account has been configured to use Email Router" alt=" CRM User whose account has been configured to use Email Router" src="images/questionmark.jpg">
                </td>
                <td style="width: 100%;">
                    <input disabled="disabled" id="userName" style="width: 80%; height: 20px; color: black; padding-bottom: 2px; padding-left: 3px; font-family: Segoe UI, Tahoma, Arial; font-size: 11px; vertical-align: middle;">
                    <img id="imgLookup" style="left: -4px; top: 6px; position: relative;" onclick="showlookupDialog();" alt="look user" src="images/lookupon.gif">
                </td>
            </tr>
            <tr>
                <td class="label" colspan="2">
                    Email Template 
                    <img title="Please leave blank to use default template provided by IOTAP" alt=" Please leave blank to use default template provided by IOTAP " src="images/questionmark.jpg">
                </td>
                <td style="width: 100%;">
                <select name="drpHtmltemplates" class="dropdown" id="drpHtmltemplates">
                    <option value=""></option>
                </select>
                </td>   
            </tr>
            <tr>
                <td class="label" colspan="2">
                    Exclude Domains 
                    <img title="Semicolon separated list of domain addresses eg. gmail.com;yahoo.com" alt=" Semicolon separated list of domain addresses eg. gmail.com;yahoo.com" src="images/questionmark.jpg">
                </td>
                <td style="width: 100%;">
					<input name="txtExcludeDomains" class="ExcludeTextbox" id="txtExcludeDomains" type="text">
                </td>   
            </tr>
			
            <tr>
                <td class="label" colspan="2">
                    Exclude Email Addresses
                    <img title="Semicolon separated list of email addresses eg. xyz@gmail.com;abc@yahoo.com" alt=" Semicolon separated list of email addresses eg. xyz@gmail.com;abc@yahoo.com" src="images/questionmark.jpg">
                </td>
                <td style="width: 100%;">
					<input name="txtExcludeUsers" class="ExcludeTextbox" id="txtExcludeUsers" type="text">
                </td>   
            </tr>
            
            <tr>
                <td class="label" colspan="3">
                    Enabled Entities
                    <img title="Select entities for which Report Scheduling will be enabled" alt=" Select entities for which Report Scheduling will be enabled" src="images/questionmark.jpg">
                </td>
            </tr>
            <tr>
                <td align="middle" class="label">
                    All
                </td>
                <td>
                    &nbsp;
                </td>
                <td align="middle" class="label">
                    Selected
                </td>
            </tr>
            <tr>
                <td style="width: 60%;">
                    <select name="entityList" class="selectlist" id="entityList" ondblclick="ToRight()" multiple="">
                    </select>
                </td>
                <td style="width: 20%;">
                    <input name="toRight" class="crmbutton" id="toRight" onclick="ToRight()" type="button" value=">>"><br>
                    <br>
                    <input name="toLeft" class="crmbutton" id="toLeft" onclick="ToLeft()" type="button" value="<<">
                </td>
                <td style="width: 60%;">
                    <select name="selectedEntityList" class="selectlist" id="selectedEntityList" ondblclick="ToLeft()" multiple="">
                    </select>
                </td>
            </tr>
            <tr>
                <td align="middle" colspan="3">
                    <input name="btnSave" class="crmbutton" id="btnSave" onclick="StartProcess();" type="button" value="Save">
                </td>
            </tr>
            <tr>
                <td colspan="3">
                </td>
            </tr>
            <tr>
                <td align="left" class="errormsg" colspan="3">
                    <span class="label" id="message"></span>
                </td>
            </tr>
        </tbody>
    </table>
    <div class="loader" id="loadingmessage" style="display: none;">
        <img alt="loading..." src="images/loading_spiner.gif">
        <input id="userId" type="hidden">
    </div>    
    <input name="txtIotap_emailbodycustomizationid" id="txtIotap_emailbodycustomizationid" type="hidden" value="">


</body></html>