<div class="modal-dialog modal-lg">
    <div class="modal-content">
        <div class="modal-header">
            <h4 class="modal-title" id="myModalLabel">
                <span class="material-icons">info_outline</span>&nbsp;<?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/dashboardwidgets','Send mass invitation message')?>
            </h4>
            <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close">

            </button>
        </div>
        <div class="modal-body">

            <?php if (isset($errors)) : ?>
                <?php include(erLhcoreClassDesign::designtpl('lhkernel/validation_error.tpl.php'));?>
            <?php endif; ?>

            <?php if (isset($message_saved) && $message_saved == 'true') : $msg = erTranslationClassLhTranslation::getInstance()->getTranslation('chat/sendnotice','Message was sent to the user'); ?>

            <script>
                <?php if (isset($chats_started) && !empty($chats_started)) : ?>
                $('#myModal').modal('hide');

                <?php foreach ($chats_started as $chat) : ?>
                    lhinst.startChat("<?php echo $chat->id?>",$('#tabs'),<?php echo json_encode((string)$chat->nick,JSON_HEX_APOS)?>);
                <?php endforeach; ?>

                <?php else : ?>
                setTimeout(function() {
                    $('#myModal').modal('hide');
                },2000);
                <?php endif; ?>
            </script>

            <?php endif; ?>


                <form action="<?php echo erLhcoreClassDesign::baseurl('chat/sendmassmessage')?>" method="post" onsubmit="return lhinst.submitModalForm($(this))">
                    
                <div id="modal-in-progress" class="alert alert-primary hide" role="alert">
                    <?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/onlineusers','In progress...');?>
                </div>

                <div class="row pb-2">
                    <div class="col-3">
                        <label><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/onlineusers','Department');?></label>
                        <?php echo erLhcoreClassRenderHelper::renderCombobox( array (
                            'input_name'     => 'mass_department_id',
                            'optional_field' => erTranslationClassLhTranslation::getInstance()->getTranslation('chat/lists/search_panel','Select department'),
                            'selected_id'    => 0,
                            'css_class'      => 'form-control form-control-sm',
                            'list_function'  => 'erLhcoreClassModelDepartament::getList',
                            'list_function_params' => $departmentParams
                        )); ?>
                    </div>
                    <?php $countryList = json_decode(
                        '[{"Code": "AF", "Name": "Afghanistan"},{"Code": "AX", "Name": "\u00c5land Islands"},{"Code": "AL", "Name": "Albania"},{"Code": "DZ", "Name": "Algeria"},{"Code": "AS", "Name": "American Samoa"},{"Code": "AD", "Name": "Andorra"},{"Code": "AO", "Name": "Angola"},{"Code": "AI", "Name": "Anguilla"},{"Code": "AQ", "Name": "Antarctica"},{"Code": "AG", "Name": "Antigua and Barbuda"},{"Code": "AR", "Name": "Argentina"},{"Code": "AM", "Name": "Armenia"},{"Code": "AW", "Name": "Aruba"},{"Code": "AU", "Name": "Australia"},{"Code": "AT", "Name": "Austria"},{"Code": "AZ", "Name": "Azerbaijan"},{"Code": "BS", "Name": "Bahamas"},{"Code": "BH", "Name": "Bahrain"},{"Code": "BD", "Name": "Bangladesh"},{"Code": "BB", "Name": "Barbados"},{"Code": "BY", "Name": "Belarus"},{"Code": "BE", "Name": "Belgium"},{"Code": "BZ", "Name": "Belize"},{"Code": "BJ", "Name": "Benin"},{"Code": "BM", "Name": "Bermuda"},{"Code": "BT", "Name": "Bhutan"},{"Code": "BO", "Name": "Bolivia, Plurinational State of"},{"Code": "BQ", "Name": "Bonaire, Sint Eustatius and Saba"},{"Code": "BA", "Name": "Bosnia and Herzegovina"},{"Code": "BW", "Name": "Botswana"},{"Code": "BV", "Name": "Bouvet Island"},{"Code": "BR", "Name": "Brazil"},{"Code": "IO", "Name": "British Indian Ocean Territory"},{"Code": "BN", "Name": "Brunei Darussalam"},{"Code": "BG", "Name": "Bulgaria"},{"Code": "BF", "Name": "Burkina Faso"},{"Code": "BI", "Name": "Burundi"},{"Code": "KH", "Name": "Cambodia"},{"Code": "CM", "Name": "Cameroon"},{"Code": "CA", "Name": "Canada"},{"Code": "CV", "Name": "Cape Verde"},{"Code": "KY", "Name": "Cayman Islands"},{"Code": "CF", "Name": "Central African Republic"},{"Code": "TD", "Name": "Chad"},{"Code": "CL", "Name": "Chile"},{"Code": "CN", "Name": "China"},{"Code": "CX", "Name": "Christmas Island"},{"Code": "CC", "Name": "Cocos (Keeling) Islands"},{"Code": "CO", "Name": "Colombia"},{"Code": "KM", "Name": "Comoros"},{"Code": "CG", "Name": "Congo"},{"Code": "CD", "Name": "Congo, the Democratic Republic of the"},{"Code": "CK", "Name": "Cook Islands"},{"Code": "CR", "Name": "Costa Rica"},{"Code": "CI", "Name": "C\u00f4te d\'Ivoire"},{"Code": "HR", "Name": "Croatia"},{"Code": "CU", "Name": "Cuba"},{"Code": "CW", "Name": "Cura\u00e7ao"},{"Code": "CY", "Name": "Cyprus"},{"Code": "CZ", "Name": "Czech Republic"},{"Code": "DK", "Name": "Denmark"},{"Code": "DJ", "Name": "Djibouti"},{"Code": "DM", "Name": "Dominica"},{"Code": "DO", "Name": "Dominican Republic"},{"Code": "EC", "Name": "Ecuador"},{"Code": "EG", "Name": "Egypt"},{"Code": "SV", "Name": "El Salvador"},{"Code": "GQ", "Name": "Equatorial Guinea"},{"Code": "ER", "Name": "Eritrea"},{"Code": "EE", "Name": "Estonia"},{"Code": "ET", "Name": "Ethiopia"},{"Code": "FK", "Name": "Falkland Islands (Malvinas)"},{"Code": "FO", "Name": "Faroe Islands"},{"Code": "FJ", "Name": "Fiji"},{"Code": "FI", "Name": "Finland"},{"Code": "FR", "Name": "France"},{"Code": "GF", "Name": "French Guiana"},{"Code": "PF", "Name": "French Polynesia"},{"Code": "TF", "Name": "French Southern Territories"},{"Code": "GA", "Name": "Gabon"},{"Code": "GM", "Name": "Gambia"},{"Code": "GE", "Name": "Georgia"},{"Code": "DE", "Name": "Germany"},{"Code": "GH", "Name": "Ghana"},{"Code": "GI", "Name": "Gibraltar"},{"Code": "GR", "Name": "Greece"},{"Code": "GL", "Name": "Greenland"},{"Code": "GD", "Name": "Grenada"},{"Code": "GP", "Name": "Guadeloupe"},{"Code": "GU", "Name": "Guam"},{"Code": "GT", "Name": "Guatemala"},{"Code": "GG", "Name": "Guernsey"},{"Code": "GN", "Name": "Guinea"},{"Code": "GW", "Name": "Guinea-Bissau"},{"Code": "GY", "Name": "Guyana"},{"Code": "HT", "Name": "Haiti"},{"Code": "HM", "Name": "Heard Island and McDonald Islands"},{"Code": "VA", "Name": "Holy See (Vatican City State)"},{"Code": "HN", "Name": "Honduras"},{"Code": "HK", "Name": "Hong Kong"},{"Code": "HU", "Name": "Hungary"},{"Code": "IS", "Name": "Iceland"},{"Code": "IN", "Name": "India"},{"Code": "ID", "Name": "Indonesia"},{"Code": "IR", "Name": "Iran, Islamic Republic of"},{"Code": "IQ", "Name": "Iraq"},{"Code": "IE", "Name": "Ireland"},{"Code": "IM", "Name": "Isle of Man"},{"Code": "IL", "Name": "Israel"},{"Code": "IT", "Name": "Italy"},{"Code": "JM", "Name": "Jamaica"},{"Code": "JP", "Name": "Japan"},{"Code": "JE", "Name": "Jersey"},{"Code": "JO", "Name": "Jordan"},{"Code": "KZ", "Name": "Kazakhstan"},{"Code": "KE", "Name": "Kenya"},{"Code": "KI", "Name": "Kiribati"},{"Code": "KP", "Name": "Korea, Democratic People\'s Republic of"},{"Code": "KR", "Name": "Korea, Republic of"},{"Code": "KW", "Name": "Kuwait"},{"Code": "KG", "Name": "Kyrgyzstan"},{"Code": "LA", "Name": "Lao People\'s Democratic Republic"},{"Code": "LV", "Name": "Latvia"},{"Code": "LB", "Name": "Lebanon"},{"Code": "LS", "Name": "Lesotho"},{"Code": "LR", "Name": "Liberia"},{"Code": "LY", "Name": "Libya"},{"Code": "LI", "Name": "Liechtenstein"},{"Code": "LT", "Name": "Lithuania"},{"Code": "LU", "Name": "Luxembourg"},{"Code": "MO", "Name": "Macao"},{"Code": "MK", "Name": "Macedonia, the Former Yugoslav Republic of"},{"Code": "MG", "Name": "Madagascar"},{"Code": "MW", "Name": "Malawi"},{"Code": "MY", "Name": "Malaysia"},{"Code": "MV", "Name": "Maldives"},{"Code": "ML", "Name": "Mali"},{"Code": "MT", "Name": "Malta"},{"Code": "MH", "Name": "Marshall Islands"},{"Code": "MQ", "Name": "Martinique"},{"Code": "MR", "Name": "Mauritania"},{"Code": "MU", "Name": "Mauritius"},{"Code": "YT", "Name": "Mayotte"},{"Code": "MX", "Name": "Mexico"},{"Code": "FM", "Name": "Micronesia, Federated States of"},{"Code": "MD", "Name": "Moldova, Republic of"},{"Code": "MC", "Name": "Monaco"},{"Code": "MN", "Name": "Mongolia"},{"Code": "ME", "Name": "Montenegro"},{"Code": "MS", "Name": "Montserrat"},{"Code": "MA", "Name": "Morocco"},{"Code": "MZ", "Name": "Mozambique"},{"Code": "MM", "Name": "Myanmar"},{"Code": "NA", "Name": "Namibia"},{"Code": "NR", "Name": "Nauru"},{"Code": "NP", "Name": "Nepal"},{"Code": "NL", "Name": "Netherlands"},{"Code": "NC", "Name": "New Caledonia"},{"Code": "NZ", "Name": "New Zealand"},{"Code": "NI", "Name": "Nicaragua"},{"Code": "NE", "Name": "Niger"},{"Code": "NG", "Name": "Nigeria"},{"Code": "NU", "Name": "Niue"},{"Code": "NF", "Name": "Norfolk Island"},{"Code": "MP", "Name": "Northern Mariana Islands"},{"Code": "NO", "Name": "Norway"},{"Code": "OM", "Name": "Oman"},{"Code": "PK", "Name": "Pakistan"},{"Code": "PW", "Name": "Palau"},{"Code": "PS", "Name": "Palestine, State of"},{"Code": "PA", "Name": "Panama"},{"Code": "PG", "Name": "Papua New Guinea"},{"Code": "PY", "Name": "Paraguay"},{"Code": "PE", "Name": "Peru"},{"Code": "PH", "Name": "Philippines"},{"Code": "PN", "Name": "Pitcairn"},{"Code": "PL", "Name": "Poland"},{"Code": "PT", "Name": "Portugal"},{"Code": "PR", "Name": "Puerto Rico"},{"Code": "QA", "Name": "Qatar"},{"Code": "RE", "Name": "R\u00e9union"},{"Code": "RO", "Name": "Romania"},{"Code": "RU", "Name": "Russian Federation"},{"Code": "RW", "Name": "Rwanda"},{"Code": "BL", "Name": "Saint Barth\u00e9lemy"},{"Code": "SH", "Name": "Saint Helena, Ascension and Tristan da Cunha"},{"Code": "KN", "Name": "Saint Kitts and Nevis"},{"Code": "LC", "Name": "Saint Lucia"},{"Code": "MF", "Name": "Saint Martin (French part)"},{"Code": "PM", "Name": "Saint Pierre and Miquelon"},{"Code": "VC", "Name": "Saint Vincent and the Grenadines"},{"Code": "WS", "Name": "Samoa"},{"Code": "SM", "Name": "San Marino"},{"Code": "ST", "Name": "Sao Tome and Principe"},{"Code": "SA", "Name": "Saudi Arabia"},{"Code": "SN", "Name": "Senegal"},{"Code": "RS", "Name": "Serbia"},{"Code": "SC", "Name": "Seychelles"},{"Code": "SL", "Name": "Sierra Leone"},{"Code": "SG", "Name": "Singapore"},{"Code": "SX", "Name": "Sint Maarten (Dutch part)"},{"Code": "SK", "Name": "Slovakia"},{"Code": "SI", "Name": "Slovenia"},{"Code": "SB", "Name": "Solomon Islands"},{"Code": "SO", "Name": "Somalia"},{"Code": "ZA", "Name": "South Africa"},{"Code": "GS", "Name": "South Georgia and the South Sandwich Islands"},{"Code": "SS", "Name": "South Sudan"},{"Code": "ES", "Name": "Spain"},{"Code": "LK", "Name": "Sri Lanka"},{"Code": "SD", "Name": "Sudan"},{"Code": "SR", "Name": "Suriname"},{"Code": "SJ", "Name": "Svalbard and Jan Mayen"},{"Code": "SZ", "Name": "Swaziland"},{"Code": "SE", "Name": "Sweden"},{"Code": "CH", "Name": "Switzerland"},{"Code": "SY", "Name": "Syrian Arab Republic"},{"Code": "TW", "Name": "Taiwan, Province of China"},{"Code": "TJ", "Name": "Tajikistan"},{"Code": "TZ", "Name": "Tanzania, United Republic of"},{"Code": "TH", "Name": "Thailand"},{"Code": "TL", "Name": "Timor-Leste"},{"Code": "TG", "Name": "Togo"},{"Code": "TK", "Name": "Tokelau"},{"Code": "TO", "Name": "Tonga"},{"Code": "TT", "Name": "Trinidad and Tobago"},{"Code": "TN", "Name": "Tunisia"},{"Code": "TR", "Name": "Turkey"},{"Code": "TM", "Name": "Turkmenistan"},{"Code": "TC", "Name": "Turks and Caicos Islands"},{"Code": "TV", "Name": "Tuvalu"},{"Code": "UG", "Name": "Uganda"},{"Code": "UA", "Name": "Ukraine"},{"Code": "AE", "Name": "United Arab Emirates"},{"Code": "GB", "Name": "United Kingdom"},{"Code": "US", "Name": "United States"},{"Code": "UM", "Name": "United States Minor Outlying Islands"},{"Code": "UY", "Name": "Uruguay"},{"Code": "UZ", "Name": "Uzbekistan"},{"Code": "VU", "Name": "Vanuatu"},{"Code": "VE", "Name": "Venezuela, Bolivarian Republic of"},{"Code": "VN", "Name": "Viet Nam"},{"Code": "VG", "Name": "Virgin Islands, British"},{"Code": "VI", "Name": "Virgin Islands, U.S."},{"Code": "WF", "Name": "Wallis and Futuna"},{"Code": "EH", "Name": "Western Sahara"},{"Code": "YE", "Name": "Yemen"},{"Code": "ZM", "Name": "Zambia"},{"Code": "ZW", "Name": "Zimbabwe"}]'
                        ,true);?>
                    <div class="col-3">
                        <label><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/onlineusers','Visitor country');?></label>
                        <select class="form-control form-control-sm" id="id_mass_country_id" title="Select country">
                            <option value=""><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/onlineusers','Select country');?></option>
                            <?php foreach ($countryList as $countryItem) : ?>
                                <option value="<?php echo htmlspecialchars(strtolower($countryItem['Code']))?>"><?php echo htmlspecialchars($countryItem['Name'])?></option>
                            <?php endforeach; ?>
                        </select>
                    </div>

                    <div class="col-3">
                        <label><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/onlineusers','Visited in the past');?></label>
                        <select class="form-control form-control-sm" id="id_mass_userTimeout" title="<?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/onlineusers','Show visitors who visited site in the past');?>">
                            <option value="30">30 <?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/onlineusers','seconds');?></option>
                            <option value="60">1 <?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/onlineusers','minute');?></option>
                            <option value="120">2 <?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/onlineusers','minutes');?></option>
                            <option value="300">5 <?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/onlineusers','minutes');?></option>
                            <option value="600">10 <?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/onlineusers','minutes');?></option>
                            <option value="1200">20 <?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/onlineusers','minutes');?></option>
                            <option value="1800">30 <?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/onlineusers','minutes');?></option>
                            <option value="3600">1 <?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/onlineusers','hour');?></option>
                            <option value="28800" selected="selected">8 <?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/onlineusers','hour');?></option>
                            <option value="43200">12 <?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/onlineusers','hour');?></option>
                            <option value="86400">1 <?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/onlineusers','day');?></option>
                            <option value="604800">7 <?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/onlineusers','days');?></option>
                            <option value="2678400">31 <?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/onlineusers','day');?></option>
                            <option value="<?php echo 60*24*3600?>">60 <?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/onlineusers','days');?></option>
                            <option value="<?php echo 90*24*3600?>">90 <?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/onlineusers','days');?></option>
                            <option value="<?php echo 120*24*3600?>">120 <?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/onlineusers','days');?></option>
                            <option value="<?php echo 150*24*3600?>">150 <?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/onlineusers','days');?></option>
                            <option value="<?php echo 180*24*3600?>">180 <?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/onlineusers','days');?></option>
                            <option value="<?php echo 200*24*3600?>">200 <?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/onlineusers','days');?></option>
                            <option value="<?php echo 300*24*3600?>">300 <?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/onlineusers','days');?></option>
                            <option value="<?php echo 365*24*3600?>">365 <?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/onlineusers','days');?></option>
                            <option value="<?php echo 500*24*3600?>">500 <?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/onlineusers','days');?></option>
                            <option value="<?php echo 600*24*3600?>">600 <?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/onlineusers','days');?></option>
                            <option value="<?php echo 1000*24*3600?>">1000 <?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/onlineusers','days');?></option>
                        </select>
                    </div>

                    <div class="col-3">
                        <label><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/onlineusers','Max records to return');?></label>
                        <select class="form-control form-control-sm" id="maxRows" title="<?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/onlineusers','Max records to return');?>">
                            <option value="50">50</option>
                            <option value="100">100</option>
                            <option value="150">150</option>
                            <option value="200">200</option>
                            <option value="250">250</option>
                            <option value="300">300</option>
                            <option value="500">500</option>
                            <option value="1000">1000</option>
                        </select>
                    </div>

                    <div class="col-4 mt-2">
                        <label><input type="checkbox" value="on" id="mass-only-online"> <?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/onlineusers','Show only connected');?></label>
                    </div>

                    <div class="col-4 mt-2">
                        <label><input type="checkbox" value="on" id="mass-only-not-chatted"> <?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/onlineusers','Never had a chat');?></label>
                    </div>

                    <div class="col-4 mt-2">
                        <label><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/onlineusers','Usernames (*.csv)');?> <span title="<?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/onlineusers','Upload usernames in CSV format');?>" id="upload-usernames-icon" class="material-icons action-image">upload_file</span>
                            <input class="hide" type="file" id="upload-usernames-action" accept=".csv">
                        </label>
                    </div>

                </div>
                <?php $sendNoticeParams = array(
                    'mode' => 'mass'
                ); ?>
                <?php include(erLhcoreClassDesign::designtpl('lhchat/onlineusers/sendnotice_content.tpl.php'));?>

                <label class="mt-2"><input id="mass_check_all" type="checkbox" value="on"> <?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('system/buttons','Check all')?></label>

                <div id="online-visitors-filtered" class="mt-2" style="max-height: 300px;overflow: auto">

                </div>

            </form>

            <script>
                (function(){

                    var timeout = null;

                    function updateFilter() {
                        clearTimeout(timeout);
                        timeout = setTimeout(function(){
                            $.post(WWW_DIR_JAVASCRIPT + 'chat/onlineusers/(method)/ajax/(timeout)/'+($('#id_mass_userTimeout').val() != '' ? $('#id_mass_userTimeout').val() : '2678400')+($('#mass-only-not-chatted').is(':checked') ? '/(nochat)/true' : '') +'/(maxrows)/' + $('#maxRows').val() + '/' + ($('#id_mass_country_id').val() != '' ? '/(country)/'+$('#id_mass_country_id').val() : '')+(parseInt($('#id_mass_department_id').val()) > 0 ? '/(department)/'+$('#id_mass_department_id').val() : '')+"?view=html",{"usernames":$('#sendToUsernames').val()}, function(data) {
                                $('#online-visitors-filtered').html(data);

                                if ($('#mass_check_all').is(':checked')) {
                                    $('.online-user-filter-row-check').prop('checked','checked');
                                    $('.filter-online-active .online-user-filter-row:not(.online_user) .online-user-filter-row-check').prop('checked',false);
                                }

                                updateCounter();
                                $('.online-user-filter-row-check').change(function(){
                                    updateCounter();
                                });

                                var items = [];
                                $('.mass-vid-list').each(function(){
                                    items.push($( this ).val());
                                });

                                ee.emitEvent('chatAdminIsOnline', [items]);

                            })
                        },350);
                    }

                    function updateCounter(){
                        $('#mass-receiver-count').text($('.online-user-filter-row input:checked').length);
                        $('#mass-receiver-count-chat').text($('.online-user-filter-row input:checked').length);
                    }

                    updateFilter();

                    $('#id_mass_department_id,#id_mass_country_id,#id_mass_userTimeout,#sendToUsernames,#maxRows,#mass-only-not-chatted').change(function(){
                        updateFilter()
                    });

                    $('#sendToUsernames').keyup(function (){
                        updateFilter()
                    });
                    
                    $('#mass_check_all').change(function(){
                       if ($(this).is(':checked')) {
                           $('.online-user-filter-row-check').prop('checked',true);
                       } else {
                           $('.online-user-filter-row-check').prop('checked', false);
                       }

                       $('.filter-online-active .online-user-filter-row:not(.online_user) .online-user-filter-row-check').prop('checked',false);

                       updateCounter();
                    });

                    $('#mass-only-online').change( function() {
                        if ($(this).is(':checked')) {
                            $('#online-visitors-filtered').addClass('filter-online-active');
                        } else {
                            $('#online-visitors-filtered').removeClass('filter-online-active');
                        }
                        updateCounter();
                    });

                    $('#upload-usernames-action').change(function(event){
                        $('#upload-usernames-icon').removeClass('text-success');
                        const formData = new FormData();
                        formData.append("file", event.target.files[0], event.target.files[0].name);
                        $.ajax({
                            url: WWW_DIR_JAVASCRIPT + 'chat/sendmassmessage?action=usernames',
                            type: 'post',
                            dataType: "JSON",
                            data: formData,
                            processData: false,
                            contentType: false,
                            success: function (data, status)
                            {
                                if (data.error === false) {
                                    $('#sendToUsernames').val(data.content);
                                    $('#upload-usernames-icon').addClass('text-success');
                                    updateFilter();
                                } else {
                                    alert(data.reason);
                                }
                                $('#upload-usernames-action').val('');
                            },
                            error: function (xhr, desc, err)
                            {
                                $('#upload-usernames-action').val('');
                            }
                        });

                    });

                })();

            </script>

<?php include(erLhcoreClassDesign::designtpl('lhkernel/modal_footer.tpl.php'));?>