<div class="container-fluid">
    <div>
        <h3>Video Settings</h3>
        <nav aria-label="breadcrumb">
            <ol class="breadcrumb">
                <li class="breadcrumb-item">
                    <a href="#">Home</a>
                </li>
                <li class="breadcrumb-item">
                    <a href="#">Settings</a>
                </li>
                <li class="breadcrumb-item active" aria-current="page">Video Settings</li>
            </ol>
        </nav>
    </div>
    <!-- Vertical Layout -->
    <div class="row">
        <div class="col-lg-6 col-md-6">
            <div class="card">
                <div class="card-body">
                    <h6 class="card-title">Videos Settings</h6>
                    <div class="all-video-settings-alert"></div>
                    <form class="all-video-settings" method="POST">
                         <div class="float-left">
                            <label for="autoplay_system" class="main-label">Autoplay System</label>
                            <br><small class="admin-info">Autplay the next video in list. </small>
                        </div>
                        <div class="form-group float-right switcher">
                            <input type="hidden" name="autoplay_system" value="off" />
                            <input type="checkbox" name="autoplay_system" id="chck-autoplay_system" value="on" <?php echo ($pt->config->autoplay_system == 'on') ? 'checked': '';?>>
                            <label for="chck-autoplay_system" class="check-trail"><span class="check-handler"></span></label>
                        </div>
                        <div class="clearfix"></div>
                        <hr>
                      
                        <div class="float-left">
                            <label for="trailer_system" class="main-label">Add Trailer With Movie</label>
                            <br><small class="admin-info">Add trailer to Movie</small>
                        </div>
                        <div class="form-group float-right switcher">
                            <input type="hidden" name="trailer_system" value="off" />
                            <input type="checkbox" name="trailer_system" id="chck-trailer_system" value="on" <?php echo ($pt->config->trailer_system == 'on') ? 'checked': '';?>>
                            <label for="chck-trailer_system" class="check-trail"><span class="check-handler"></span></label>
                        </div>
                        <div class="clearfix"></div>
                        <hr>
                        <div class="float-left">
                            <label for="restrict_embedding_system" class="main-label">Embed Restriction</label>
                            <br><small class="admin-info">Allow users to restrict specific videos from embeding. </small>
                        </div>
                        <div class="form-group float-right switcher">
                            <input type="hidden" name="restrict_embedding_system" value="off" />
                            <input type="checkbox" name="restrict_embedding_system" id="chck-restrict_embedding_system" value="on" <?php echo ($pt->config->restrict_embedding_system == 'on') ? 'checked': '';?>>
                            <label for="chck-restrict_embedding_system" class="check-trail"><span class="check-handler"></span></label>
                        </div>
                        <div class="clearfix"></div>
                        <hr>
                       
                        <div class="float-left">
                            <label for="video_text_system" class="main-label">Video Card System</label>
                            <br><small class="admin-info">Allow users to create cards in videos.</small>
                        </div>
                        <div class="form-group float-right switcher">
                            <input type="hidden" name="video_text_system" value="off" />
                            <input type="checkbox" name="video_text_system" id="chck-video_text_system" value="on" <?php echo ($pt->config->video_text_system == 'on') ? 'checked': '';?>>
                            <label for="chck-video_text_system" class="check-trail"><span class="check-handler"></span></label>
                        </div>
                        <div class="clearfix"></div>
                        <hr>
                        <div class="float-left">
                            <label for="stock_videos" class="main-label">Stock Videos</label>
                            <br><small class="admin-info">Allow users to sell stock videos. </small>
                        </div>
                        <div class="form-group float-right switcher">
                            <input type="hidden" name="stock_videos" value="off" />
                            <input type="checkbox" name="stock_videos" id="chck-stock_videos" value="on" <?php echo ($pt->config->stock_videos == 'on') ? 'checked': '';?>>
                            <label for="chck-stock_videos" class="check-trail"><span class="check-handler"></span></label>
                        </div>
                        <div class="clearfix"></div>
                        <hr>
                        <div class="float-left">
                            <label for="download_videos" class="main-label">Download Videos</label>
                            <br><small class="admin-info">Allow users to download videos from your site. </small>
                        </div>
                        <div class="form-group float-right switcher">
                            <input type="hidden" name="download_videos" value="off" />
                            <input type="checkbox" name="download_videos" id="chck-download_videos" value="on" <?php echo ($pt->config->download_videos == 'on') ? 'checked': '';?>>
                            <label for="chck-download_videos" class="check-trail"><span class="check-handler"></span></label>
                        </div>
                        <div class="clearfix"></div>
                        <hr>
                        <div class="float-left">
                            <label for="approve_videos" class="main-label">Video Approval System</label>
                            <br><small class="admin-info">Admins should approve videos before they are being published.</small>
                        </div>
                        <div class="form-group float-right switcher">
                            <input type="hidden" name="approve_videos" value="off" />
                            <input type="checkbox" name="approve_videos" id="chck-approve_videos" value="on" <?php echo ($pt->config->approve_videos == 'on') ? 'checked': '';?>>
                            <label for="chck-approve_videos" class="check-trail"><span class="check-handler"></span></label>
                        </div>
                        <div class="clearfix"></div>
                        <hr>
                         <div class="float-left">
                            <label for="movies_videos" class="main-label">Movies System</label>
                            <br><small class="admin-info">Allow users to add movies to your site. </small>
                        </div>
                        <div class="form-group float-right switcher">
                            <input type="hidden" name="movies_videos" value="off" />
                            <input type="checkbox" name="movies_videos" id="chck-movies_videos" value="on" <?php echo ($pt->config->movies_videos == 'on') ? 'checked': '';?>>
                            <label for="chck-movies_videos" class="check-trail"><span class="check-handler"></span></label>
                        </div>
                        <div class="clearfix"></div>
                        <hr>
                        <div class="float-left">
                            <label for="require_login" class="main-label">Require Login To Watch Videos</label>
                            <br><small class="admin-info">Users should login to your site to watch videos. </small>
                        </div>
                        <div class="form-group float-right switcher">
                            <input type="hidden" name="require_login" value="off" />
                            <input type="checkbox" name="require_login" id="chck-require_login" value="on" <?php echo ($pt->config->require_login == 'on') ? 'checked': '';?>>
                            <label for="chck-require_login" class="check-trail"><span class="check-handler"></span></label>
                        </div>
                        <div class="clearfix"></div>
                        <hr>
                         <div class="float-left">
                            <label for="geo_blocking" class="main-label">Geo-Blocking</label>
                            <br><small class="admin-info">Allow users to block videos geography. </small>
                        </div>
                        <div class="form-group float-right switcher">
                            <input type="hidden" name="geo_blocking" value="off" />
                            <input type="checkbox" name="geo_blocking" id="chck-geo_blocking" value="on" <?php echo ($pt->config->geo_blocking == 'on') ? 'checked': '';?>>
                            <label for="chck-geo_blocking" class="check-trail"><span class="check-handler"></span></label>
                        </div>
                        <div class="clearfix"></div>
                    </form>
                </div>
            </div>
        </div>
        <div class="col-lg-6 col-md-6">
            <div class="card">
                <div class="card-body">
                    <h6 class="card-title">Player Settings</h6>
                    <div class="alert alert-warning">
                    <i class="fa fa-fw fa-exclamation-triangle"></i> <strong>Note:</strong> For youtube videos, the default player will be always used, the options below work for self hosted videos.
                  </div>
                    <div class="player_settings-alert"></div>
                    <form class="player-settings" method="POST">
                        <label for="player_type">Default Video Player</label>
                        <br><small class="admin-info">Select the default video player. </small>
                        <div class="form-group">
                            <select class="form-control show-tick" id="player_type" name="player_type">
                                <option value="default" <?php echo ($pt->config->player_type == 'default') ? 'selected': '';?>>Default (This player support  Video Ads , Image Ads , Vast/Vpaid Ads )</option>
                                <option value="fluidPlayer" <?php echo ($pt->config->player_type == 'fluidPlayer') ? 'selected': '';?>>Fluid Player (This player support Vast/Vpaid Ads , Image Ads)</option>
                                <option value="videojs" <?php echo ($pt->config->player_type == 'videojs') ? 'selected': '';?>>Video js Player (This player support Video Ads , Image Ads)</option>
                                <option value="cloudinary" <?php echo ($pt->config->player_type == 'cloudinary') ? 'selected': '';?>>Cloudinary Player (This player support Vast/Vpaid Ads , Image Ads)</option>
                                <option value="plyr" <?php echo ($pt->config->player_type == 'plyr') ? 'selected': '';?>>plyr.io Player (This player support Vast/Vpaid Ads , Image Ads)</option>
                            </select>
                        </div>
                        <hr>
                        <div class="float-left">
                            <label for="sticky_video" class="main-label">Sticky Video Player</label>
                            <br><small class="admin-info">On scrolldown, the video player will stick and become fixed in the screen.</small>
                        </div>
                        <div class="form-group float-right switcher">
                            <input type="hidden" name="sticky_video" value="off" />
                            <input type="checkbox" name="sticky_video" id="chck-sticky_video" value="on" <?php echo ($pt->config->sticky_video == 'on') ? 'checked': '';?>>
                            <label for="chck-sticky_video" class="check-trail"><span class="check-handler"></span></label>
                        </div>
                        <div class="clearfix"></div>
                        <hr>
                         <div class="float-left">
                            <label for="resize_video" class="main-label">Resize Video Player</label>
                            <br><small class="admin-info">Allow users to resize the video player to cinema mode. </small>
                        </div>
                        <div class="form-group float-right switcher">
                            <input type="hidden" name="resize_video" value="off" />
                            <input type="checkbox" name="resize_video" id="chck-resize_video" value="on" <?php echo ($pt->config->resize_video == 'on') ? 'checked': '';?>>
                            <label for="chck-resize_video" class="check-trail"><span class="check-handler"></span></label>
                        </div>
                         <div class="clearfix"></div>
                        <hr>
                         <div class="float-left">
                            <label for="embed_system" class="main-label">Embed Video Player</label>
                            <br><small class="admin-info">Allow users to embed videos from site. </small>
                        </div>
                        <div class="form-group float-right switcher">
                            <input type="hidden" name="embed_system" value="off" />
                            <input type="checkbox" name="embed_system" id="chck-embed_system" value="on" <?php echo ($pt->config->embed_system == 'on') ? 'checked': '';?>>
                            <label for="chck-embed_system" class="check-trail"><span class="check-handler"></span></label>
                        </div>
                        <div class="clearfix"></div>
                        <hr>
                        <div class="form-group form-float">
                            <div class="form-line">
                                <label class="form-label">Video Player Watermark</label>
                                <input type="text" name="watermark" class="form-control" value="<?php echo ($pt->config->watermark);?>">
                                <small class="admin-info">Set a URL of an image to show on your videos, jpg, png or jpeg url allowed.</small>
                            </div>
                        </div>
                        <div class="clearfix"></div>
                    </form>
                </div>
            </div>
            <div class="card">
                <div class="card-body">
                    <h6 class="card-title">Paid Videos Settings</h6>
                    <div class="paid-video-settings-alert"></div>
                    <form class="paid-video-settings" method="POST">
                        <div class="float-left">
                            <label for="sell_videos_system" class="main-label">Paid Videos System</label>
                            <br><small class="admin-info">Users can sell their own videos & earn money. </small>
                        </div>
                        <div class="form-group float-right switcher">
                            <input type="hidden" name="sell_videos_system" value="off" />
                            <input type="checkbox" name="sell_videos_system" id="chck-sell_videos_system" value="on" <?php echo ($pt->config->sell_videos_system == 'on') ? 'checked': '';?>>
                            <label for="chck-sell_videos_system" class="check-trail"><span class="check-handler"></span></label>
                        </div>
                        <div class="clearfix"></div>
                        <hr>
                        <label for="who_sell">Video Selling Restriction</label>
                        <br><small class="admin-info">Who can sell videos? </small>
                        <div class="form-group">
                            <select class="form-control show-tick" id="who_sell" name="who_sell">
                                <option value="users" <?php echo ($pt->config->who_sell == 'users') ? 'selected': '';?>>All Users</option>
                                <option value="pro_users" <?php echo ($pt->config->who_sell == 'pro_users') ? 'selected': '';?>>Pro Members Only</option>
                            </select>
                        </div>
                        <hr>
                        <div class="float-left">
                            <label for="auto_approve_" class="main-label">Auto Approve Selling Videos?</label>
                            <br><small class="admin-info">Auto approve videos wihtout reviewing.</small>
                        </div>
                        <div class="form-group float-right switcher">
                            <input type="hidden" name="auto_approve_" value="no" />
                            <input type="checkbox" name="auto_approve_" id="chck-auto_approve_" value="yes" <?php echo ($pt->config->auto_approve_ == 'yes') ? 'checked': '';?>>
                            <label for="chck-auto_approve_" class="check-trail"><span class="check-handler"></span></label>
                        </div>
                        <div class="clearfix"></div>
                        <hr>
                          <div class="float-left">
                            <label for="demo_video" class="main-label">Create Demo Video</label>
                            <br><small class="admin-info">Allow users to upload a demo version of the selling video, FFMPEG is required.</small>
                        </div>
                        <div class="form-group float-right switcher">
                            <input type="hidden" name="demo_video" value="off" />
                            <input type="checkbox" name="demo_video" id="chck-demo_video" value="on" <?php echo ($pt->config->demo_video == 'on') ? 'checked': '';?>>
                            <label for="chck-demo_video" class="check-trail"><span class="check-handler"></span></label>
                        </div>
                        <div class="clearfix"></div>
                        <hr>
                        <label for="com_type">Commission Type</label>
                        <br><small class="admin-info">Choose the commission type you want to earn?</small>
                        <div class="form-group">
                            <select class="form-control show-tick" id="com_type" name="com_type">
                                <option value="0" <?php echo ($pt->config->com_type == '0') ? 'selected': '';?>>Fixed Price From Each Video</option>
                                <option value="1" <?php echo ($pt->config->com_type == '1') ? 'selected': '';?>>Percentage From Each Video</option>
                            </select>
                        </div>
                        <div class="form-group form-float">
                            <div class="form-line">
                                <label class="form-label">Commission Amount</label>
                                <input type="text" name="admin_com_sell_videos" class="form-control" value="<?php echo ($pt->config->admin_com_sell_videos);?>">
                                <small class="admin-info">How much you want to get from each video, Set to 0 if you don't want to get any commissions.</small>
                            </div>
                        </div>
                        <div class="clearfix"></div>
                        <hr>
                        
                      
                        <div class="float-left">
                            <label for="rent_videos_system" class="main-label">Rent Videos System</label>
                            <br><small class="admin-info">Allow users to rent out videos.</small>
                        </div>
                        <div class="form-group float-right switcher">
                            <input type="hidden" name="rent_videos_system" value="off" />
                            <input type="checkbox" name="rent_videos_system" id="chck-rent_videos_system" value="on" <?php echo ($pt->config->rent_videos_system == 'on') ? 'checked': '';?>>
                            <label for="chck-rent_videos_system" class="check-trail"><span class="check-handler"></span></label>
                        </div>
                        <div class="clearfix"></div>
                        <div class="form-group form-float">
                            <div class="form-line">
                                <label class="form-label">Renting Commission Amount </label>
                                <input type="text" name="admin_com_rent_videos" class="form-control" value="<?php echo ($pt->config->admin_com_rent_videos);?>">
                               <small class="admin-info">How much you want to get from each video, Set to 0 if you don't want to get any commissions.</small>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
           
        </div>
    </div>
<script type="text/javascript">
$(function() {
    $('.switcher input[type=checkbox]').click(function () {
        var configName = $(this).attr('name');
        var hash_id = $('input[name=hash_id]').val();
        var objData = {};
        if ($(this).is(":checked") === true) {
            objData[configName] = $(this).val();
        }
        else{
            if ($('input[name='+configName+']')[0]) {
                objData[configName] = $($('input[name='+configName+']')[0]).val();
            }
        }
        objData['hash_id'] = hash_id;
        $.post('{{LINK aj/ap/save-settings}}', objData);
    });

    var setTimeOutColor = setTimeout(function (){});
    $('select').on('change', function() {
         clearTimeout(setTimeOutColor);
        var thisElement = $(this);
        var configName = thisElement.attr('name');
        var hash_id = $('input[name=hash_id]').val();
        var objData = {};
        objData[configName] = this.value;
        objData['hash_id'] = hash_id;
        thisElement.addClass('warning');
        $.post("{{LINK aj/ap/save-settings}}", objData, function (data) {
            if (data.status == 200) {
                thisElement.removeClass('warning');
                thisElement.addClass('success');
            } else {
                thisElement.addClass('error');
            }
            var setTimeOutColor = setTimeout(function () {
                thisElement.removeClass('success');
                thisElement.removeClass('warning');
                thisElement.removeClass('error');
            }, 2000);
        });
    });
    $('input[type=text], input[type=number] , textarea').on('keyup', delay(function() {
            clearTimeout(setTimeOutColor);
            var thisElement = $(this);
            var configName = thisElement.attr('name');
            var hash_id = $('input[name=hash_id]').val();
            var objData = {};
            objData[configName] = this.value;
            objData['hash_id'] = hash_id;
            thisElement.addClass('warning');
            $.post("{{LINK aj/ap/save-settings}}", objData, function (data) {
                if (data.status == 200) {
                    thisElement.removeClass('warning');
                    thisElement.addClass('success');
                } else {
                    thisElement.addClass('error');
                }
                var setTimeOutColor = setTimeout(function () {
                    thisElement.removeClass('success');
                    thisElement.removeClass('warning');
                    thisElement.removeClass('error');
                }, 2000);
                //thisElement.focus();
            });
    }, 500));
});
    $(function() {
        var upload_settings = $('form.upload-settings');
        var player_settings = $('form.player-settings');
        

        upload_settings.ajaxForm({
            url: '{{LINK aj/ap/save-settings}}',
            beforeSend: function() {
                upload_settings.find('.waves-effect').text("{{LANG please_wait}}");
            },
            success: function(data) {
                if (data.status == 200) {
                    upload_settings.find('.waves-effect').text('Save');
                    $('.upload_settings-alert').html('<div class="alert alert-success"><i class="fa fa-check"></i> Settings updated successfully</div>');
                    setTimeout(function () {
                        $('.upload_settings-alert').empty();
                    }, 2000);
                }
            }
        });
        player_settings.ajaxForm({
            url: '{{LINK aj/ap/save-settings}}',
            beforeSend: function() {
                player_settings.find('.waves-effect').text("{{LANG please_wait}}");
            },
            success: function(data) {
                if (data.status == 200) {
                    player_settings.find('.waves-effect').text('Save');
                    $('.player_settings-alert').html('<div class="alert alert-success"><i class="fa fa-check"></i> Settings updated successfully</div>');
                    setTimeout(function () {
                        $('.player_settings-alert').empty();
                    }, 2000);
                }
            }
        });
        var stock_settings = $('form.stock-settings');

        stock_settings.ajaxForm({
            url: '{{LINK aj/ap/save-settings}}',
            beforeSend: function() {
                stock_settings.find('button').text("{{LANG please_wait}}");
            },
            success: function(data) {
                if (data.status == 200) {
                    stock_settings.find('button').text('Save');
                    $('.stock-settings-alert').html('<div class="alert alert-success"><i class="fa fa-check"></i> Settings updated successfully</div>');
                    setTimeout(function () {
                        $('.stock-settings-alert').empty();
                    }, 2000);
                }
            }
        });
        var form_paid_videos_settings = $('form.paid-video-settings');

        form_paid_videos_settings.ajaxForm({
            url: '{{LINK aj/ap/save-settings}}',
            beforeSend: function() {
                form_paid_videos_settings.find('button').text("{{LANG please_wait}}");
            },
            success: function(data) {
                if (data.status == 200) {
                    form_paid_videos_settings.find('button').text('Save');
                    $('.paid-video-settings-alert').html('<div class="alert alert-success"><i class="fa fa-check"></i> Settings updated successfully</div>');
                    setTimeout(function () {
                        $('.paid-video-settings-alert').empty();
                    }, 2000);
                }
            }
        });
        var form_all_videos_settings = $('form.all-video-settings');
        form_all_videos_settings.ajaxForm({
            url: '{{LINK aj/ap/save-settings}}',
            beforeSend: function() {
                form_all_videos_settings.find('button').text("{{LANG please_wait}}");
            },
            success: function(data) {
                if (data.status == 200) {
                    form_all_videos_settings.find('button').text('Save');
                    $('.all-video-settings-alert').html('<div class="alert alert-success"><i class="fa fa-check"></i> Settings updated successfully</div>');
                    setTimeout(function () {
                        $('.all-video-settings-alert').empty();
                    }, 2000);
                }
            }
        });
    });
</script>