<?
### Версия ПО (ДМ) 1.0.0.0 ( (c)2018 MISOFT Продукт защищен регистрацией патента и авторских прав! www.misoft.studio )
######################################################################################################################

session_start();

header( 'Content-type: text/html; charset=windows-1251' );

define( 'ROOT_DIR', $_SERVER['DOCUMENT_ROOT'] );

include_once ROOT_DIR . '/engine/config.php';
include_once ROOT_DIR . '/engine/function.php';

if ( $_SERVER['HTTP_X_REQUESTED_WITH'] != 'XMLHttpRequest' ) { exit(); }
if ( !isset( $_SESSION['iduser'] ) ) exit();
if ( $config_user['account'] != 5 AND $config_user['account'] != 2 ) exit();


?>
  <script type="text/javascript">
    function delbanserg2(e) {
	  $.post('ajax.php?func=chatdel', {
		id: e
	  }, function(data) {
		if (data == 1) {
		  $('#user'+e).fadeOut(300);
		} else {
		  $('body').Qnotify({text:data, sound:'error'});	
		}
	  });
	  return false;
	}
  </script>
  <div class="modal fade bd-example-modal-lg" id="modalf">
	  <div class="modal-dialog modal-lg" role="document">
		<div class="modal-content">
		  <div class="modal-header">
			<button type="button" class="close" data-dismiss="modal" aria-label="Close">
			  <span aria-hidden="true">&times;</span>
			</button>
			<h4 class="modal-title">Заблокированные пользователи чата</h4>
		  </div>
		  
		  <div class="modal-body"><!--Содержимое модального окна начало-->
			
			<div style="padding: 3px; margin:1px; text-align:left; overflow-y: scroll; height: 600px;">
			  <?	
				$select_chat_ban = mysql_query( "SELECT * FROM chat_ban ORDER BY timeban DESC" );
				if ( mysql_num_rows( $select_chat_ban ) > 0 ) {
				  ?>
					<table class="table" >
					  <thead>
						<tr>
						  <th>Пользователь</th>
						  <th>Причина блокировки</th>
						  <th>Дата завершения</th>
						  <th>#</th>
						</tr>
					  </thead>
					  <tbody style="">
						<?
						  while ( $select_chat_ban_row = mysql_fetch_array( $select_chat_ban ) ) {
							$chat_ban_user = mysql_fetch_array( mysql_query( "SELECT id, username, avatar FROM user WHERE id = '" . $select_chat_ban_row['iduser'] . "'" ) );
							if ( $select_chat_ban_row['type'] == 1 ) {
								
							} else {
								
							}
							$month = array( 'янв', 'фев', 'мар', 'апр', 'май', 'июн', 'июл', 'авг', 'сен', 'окт', 'ноя', 'дек' );
							$comm_time = ( int ) date( 'd', $select_chat_ban_row['timeban'] ) . ' ' . $month[( int ) date( 'm', $select_chat_ban_row['timeban'] ) - 1] . ' ' . date( 'Y', $select_chat_ban_row['timeban'] ) . ' в ' . date( 'H:i', $select_chat_ban_row['timeban'] );
							?>
							  <tr id="user<?=$chat_ban_user['id']?>">
								<td >
								  <img src="/temp/avatar/<?=$chat_ban_user['avatar']?>" width="24" height="24" class="img-circle" alt="" /> 
								  <div style="margin: -28px 0 0 35px;"><?=$chat_ban_user['username']?></div>
								</td>
								<td width="410" style="font-size: 13px;"><?=$select_chat_ban_row['coment']?></td>
								<td width="150"><?=$comm_time?></td>
								<td>
								  <i onclick="delbanserg2(<?=$chat_ban_user['id']?>); return false;" class="fa fa-times chat-ban-close" aria-hidden="true"></i>
								</td>
							  </tr>
						   <?
					      } 
						?>
					  </tbody>
				    </table>
				  <?
				} else {
					?>
					  <div class="div_centralizator">
					    <div class="vertical-align-paragraph"><i class="fa fa-meh-o" aria-hidden="true"></i> Нарушителей не найдено</div>
					  </div>
					<?
				}
			  ?>	  
			</div>
			
		  </div><!--Содержимое модального окна конец-->
		  
		  <div class="modal-footer">
			<button type="button" class="btn btn-secondary" data-dismiss="modal">Закрыть</button>
		  </div>
		</div>
	  </div>
  </div>
	
  <script type="text/javascript">
	$(document).ready(function(){
		var options = {
			show : true
		}
		$('#modalf').modal(options);
	});

	
</script>