<script
	language="javascript" type="text/javascript">
	<!--
	function addEvent(elem, type, handler) {
if (elem.addEventListener) {
elem.addEventListener(type, handler, false)
} else {
elem.attachEvent("on" + type, handler)
}
}
// DateEdit filter
function filter_attach_DateEdit(id) {
var field = document.getElementById(id);
if (! field)
return false;

if (field.value == '')
field.value = 'DD.MM.YYYY';

field.onfocus = function (event) {
var ev = event ? event : window.event;
var elem = ev.target ? ev.target : ev.srcElement;
if (elem.value == 'DD.MM.YYYY')
elem.value = '';

return true;
}
field.onkeypress = function (event) {
var ev = event ? event : window.event;
var keyCode = ev.keyCode ? ev.keyCode : ev.charCode;
var elem = ev.target ? ev.target : ev.srcElement;
var elv = elem.value;
isMozilla = false;
isIE = false;
isOpera = false;
if (navigator.appName == 'Netscape') {
isMozilla = true;
} else if (navigator.appName == 'Microsoft Internet Explorer') {
isIE = true;
} else if (navigator.appName == 'Opera') {
isOpera = true;
} else { /* alert('Unknown navigator: `'+navigator.appName+'`'); */
}
// document.getElementById('debugWin').innerHTML = 'keyPress('+ev.keyCode+':'+ev.charCode+')['+(ev.shiftKey?'S':'.')+(ev.ctrlKey?'C':'.')+(ev.altKey?'A':'.')+']<br/>' + document.getElementById('debugWin').innerHTML;
// FF - onKeyPress captures functional keys. Skip anything with charCode = 0
if (isMozilla && ! ev.charCode)
return true;

// Opera - dumb browser, don't let us to determine some keys
if (isOpera) {
var ek = '';
// for (i in event) { ek = ek + '['+i+']: '+event[i]+'<br/>\n'; }
// alert(ek);
if (ev.keyCode < 32)
return true;

if (! ev.shiftKey && ((ev.keyCode >= 33) && (ev.keyCode<= 47))) return true;
			if (!ev.keyCode) return true;
			if (!ev.which) return true;
		}
		// Don't block CTRL / ALT keys
		if (ev.altKey || ev.ctrlKey || !keyCode)
			return true;
		// Allow to input only digits [0..9] and dot [.]
		if (((keyCode> = 48) && (keyCode <= 57)) || (keyCode == 46))
return true;

return false;
}
return true;
}
	-->
</script>
<div class="comments-area" style=" margin-bottom: 30px;">
	<div class="row mb-2">
		<div class="col-sm-6 d-none d-md-block ">
			<h3>
				{{ lang.editnews['news_title'] }}</h3>
		</div>
		<!-- /.col -->
		<div class="col-sm-6">
			<ol class="breadcrumb float-sm-right">
				<li class="breadcrumb-item">
					<a href="{{ php_self }}">
						<i class="fa fa-home"></i>
					</a>
				</li>
				<li class="breadcrumb-item active" aria-current="page">
					<a href="?mod=news">
						{{ lang.editnews['news_title'] }}</a>
				</li>
			</ol>
		</div>
		<!-- /.col -->
	</div>
	<!-- /.row -->
</div>
<!-- DEBUG WINDOW <div id="debugWin" style="overflow: auto; position: absolute; top: 160px; left: 230px; width: 400px; height: 400px; background: white; 4px double black; padding: 2px; margin: 2px;">DEBUG WINDOW</div> -->
<div class="comments-area">
	<form action="{{ php_self }}?mod=news" method="post" name="options_bar" style="padding: 15px;">
		<div
			class="row" style="margin-bottom: 15px;border: 1px solid #ddd;">
			<!-- Колонка 1: Поиск и Автор -->
			<div class="col-md-4">
				<div class="form-group">
					<label>Поиск</label>
					<div class="input-group">
						<input name="sl" type="text" class="form-control" value="{{ sl }}" placeholder="Введите текст"/>
						<select name="st" class="form-control" style="max-width: 120px;">
							<option value="0" {{ st.selected0 }}>заголовок</option>
							<option value="1" {{ st.selected1 }}>текст</option>
						</select>
					</div>
				</div>
				<div class="form-group">
					<label>{{ lang.editnews.author }}</label>
					<div style="position: relative;">
						<input name="an" id="an" class="form-control" type="text" value="{{ an }}" autocomplete="off"/>
						<span id="suggestLoader" style="position: absolute; right: 10px; top: 8px; width: 20px; visibility: hidden;">
							<img src="{{ skins_url }}/images/loading.gif"/>
						</span>
					</div>
				</div>
			</div>
			<!-- Колонка 2: Дата и Категория -->
			<div class="col-md-4">
				<div class="form-group">
					<label>Дата</label>
					<div class="input-group mb-2">
						<div class="input-group-prepend">
							<span class="input-group-text">с:</span>
						</div>
						<input type="text" id="dr1" name="dr1" value="{{ dr1 }}" class="form-control" placeholder="DD.MM.YYYY"/>
					</div>
					<div class="input-group">
						<div class="input-group-prepend">
							<span class="input-group-text">по:</span>
						</div>
						<input type="text" id="dr2" name="dr2" value="{{ dr2 }}" class="form-control" placeholder="DD.MM.YYYY"/>
					</div>
				</div>
				<div class="form-group">
					<label>{{ lang.editnews['category'] }}</label>
					{{ category_select }}
				</div>
			</div>
			<!-- Колонка 3: Статус, На странице и Сортировка -->
			<div class="col-md-4">
				<div class="row">
					<div class="col-6">
						<div class="form-group">
							<label>Статус</label>
							<select name="status" class="form-control">
								<option value="">{{ lang.editnews['smode_all'] }}</option>
								{{ statuslist }}
							</select>
						</div>
					</div>
					<div class="col-6">
						<div class="form-group">
							<label>На странице</label>
							<input name="rpp" value="{{ rpp }}" type="text" class="form-control"/>
						</div>
					</div>
				</div>
				<div class="form-group">
					<label>{{ lang.editnews['sort'] }}</label>
					<select name="sort" class="form-control">{{ sortlist }}</select>
				</div>
			</div>
		</div>
		<!-- Кнопка показать внизу -->
		<div class="row">
			<div class="col-12 text-right">
				<input type="submit" value="{{ lang.editnews['do_show'] }}" class="btn btn-primary" style="min-width: 150px;"/>
			</div>
		</div>
	</form>
	<!-- Конец блока фильтрации -->
	<br/>
	<!-- List of news start here -->
	<form action="{{ php_self }}?mod=news" method="post" name="editnews">
		<input type="hidden" name="token" value="{{ token }}"/>
		<input type="hidden" name="mod" value="news"/>
		<input type="hidden" name="action" value="manage"/>
		<table border="0" cellspacing="0" cellpadding="0" class="content" align="center">
			<tr align="left" class="contHead">
				<td nowrap>{{ lang.editnews['postid_short'] }}</td>
				<td nowrap>{{ lang.editnews['date'] }}</td>
				<td>&nbsp;</td>
				<td>{{ lang.editnews['title'] }}</td>
				{% if flags.comments %}
					<td style=" text-align:right;">
						<i class="fa fa-comments-o"></i>
					</td>
				{% endif %}
				<td style=" text-align:right;">
					<i class="fa fa-eye"></i>
				</td>
				<td>{{ lang.editnews['category'] }}</td>
				<td>{{ lang.editnews['author'] }}</td>
				<td>&nbsp;</td>
				<td><input class="check" type="checkbox" name="master_box" title="{{ lang.editnews['select_all'] }}" onclick="javascript:check_uncheck_all(editnews)"/></td>
			</tr>
			{% for entry in entries %}
				<tr align="left">
					<td class="contentEntry1">{{ entry.newsid }}</td>
					<td class="contentEntry1">{{ entry.itemdate }}</td>
					<td class="contentEntry1" cellspacing="0" cellpadding="0" style="padding:0; margin:0;" nowrap>
						{% if entry.flags.mainpage %}
							<i class="fa fa-home" title="Main"></i>
						{% endif %}
						{% if (entry.attach_count > 0) %}
							<i class="fa fa-paperclip" title="{{ lang['attach.count'] }}: {{ entry.attach_count }}"></i>
						{% endif %}
						{% if (entry.images_count > 0) %}
							<i class="fa fa-file-image-o" title="{{ lang['images.count'] }}: {{ entry.images_count }}"></i>
						{% endif %}
					</td>
					<td class="contentEntry1">
						{% if entry.flags.editable %}
							<a href="{{ php_self }}?mod=news&amp;action=edit&amp;id={{ entry.newsid }}">
							{% endif %}
							{{ entry.title }}
							{% if entry.flags.editable %}
							</a>
						{% endif %}
					</td>
					{% if entry.flags.comments %}
						<td class="contentEntry1" style=" text-align:right;">
							{% if (entry.comments > 0) %}
								{{ entry.comments }}
							{% endif %}
						</td>
						<td class="contentEntry1" style=" text-align:right;">
							{% if entry.flags.isActive %}
								<a href="{{ entry.link }}" target="_blank">
								{% endif %}
								{% if (entry.views > 0) %}
									{{ entry.views }}{% else %}-
								{% endif %}
								{% if entry.flags.isActive %}
								</a>
							{% endif %}
						</td>
					{% endif %}
					<td class="contentEntry1">{{ entry.allcats }}</td>
					<td class="contentEntry1">
						<a href="{{ php_self }}?mod=users&amp;action=editForm&amp;id={{ entry.userid }}">{{ entry.username }}</a>
					</td>
					<td class="contentEntry1">
						{% if (entry.state == 1) %}
							<i class="fa fa-check" title="{{ lang['state.published'] }}"></i>
						{% elseif (entry.state == 0) %}
							<i class="fa fa-times" title="{{ lang['state.unpiblished'] }}"></i>
						{% else %}
							<i class="fa fa-circle-o" title="{{ lang['state.draft'] }}"></i>
						{% endif %}
					</td>
					<td class="contentEntry1"><input name="selected_news[]" value="{{ entry.newsid }}" class="check" type="checkbox"/></td>
				</tr>
			{% else %}
				<tr>
					<td colspan="6">
						<p>-
							{{ lang.editnews['not_found'] }}
							-</p>
					</td>
				</tr>
			{% endfor %}
			<tr>
				<td width="100%" colspan="8">&nbsp;</td>
			</tr>
			{% if flags.allow_modify %}
				<tr align="center">
					<td colspan="8" class="contentEdit" align="right" valign="top">
						<div style="text-align: left;">
							{{ lang.editnews['action'] }}:
							<select name="subaction" style="font: 12px Verdana, Courier, Arial; width: 230px;">
								<option value="">--
									{{ lang.editnews['action'] }}
									--</option>
								<option value="mass_approve">{{ lang.editnews['approve'] }}</option>
								<option value="mass_forbidden">{{ lang.editnews['forbidden'] }}</option>
								<option value="" style="background-color: #E0E0E0;" disabled="disabled">===================</option>
								<option value="mass_mainpage">{{ lang.editnews['massmainpage'] }}</option>
								<option value="mass_unmainpage">{{ lang.editnews['massunmainpage'] }}</option>
								<option value="" style="background-color: #E0E0E0;" disabled="disabled">===================</option>
								<option value="mass_currdate">{{ lang.editnews['modify.mass.currdate'] }}</option>
								<option value="" style="background-color: #E0E0E0;" disabled="disabled">===================</option>
								{% if flags.comments %}
									<option value="mass_com_approve">{{ lang.editnews['com_approve'] }}</option>
									<option value="mass_com_forbidden">{{ lang.editnews['com_forbidden'] }}</option>
									<option value="" style="background-color: #E0E0E0;" disabled="disabled">===================</option>
								{% endif %}
								<option value="mass_delete">{{ lang.editnews['delete'] }}</option>
							</select>
							<input type="submit" value="{{ lang.editnews['submit'] }}" class="button"/>
							<br/>
						</div>
					</td>
				</tr>
				<tr>
					<td width="100%" colspan="8">&nbsp;</td>
				</tr>
			{% endif %}
			<tr>
				<td align="center" colspan="8" class="contentHead">{{ pagesss }}</td>
			</tr>
		</table>
	</form>
</div>
<script type="text/javascript" src="{{ scriptLibrary }}/ajax.js"></script>
<script type="text/javascript" src="{{ scriptLibrary }}/libsuggest.js"></script>
<script type="text/javascript">
	$('#dr1, #dr2').datetimepicker({format: "d.m.Y"});
$(document).ready(function () {
var aSuggest = new ngSuggest('an', {
'localPrefix': '{{ localPrefix }}',
'reqMethodName': 'core.users.search',
'lId': 'loading-layer',
'hlr': 'true',
'iMinLen': 1,
'stCols': 2,
'stColsClass': [
'cleft', 'cright'
],
'stColsHLR': [true, false]
});
});
</script>
<script>
	<!--
	// INIT NEW SUGGEST LIBRARY [ call only after full document load ]
function systemInit() {
var aSuggest = new ngSuggest('an', {
'localPrefix': '{{ localPrefix }}',
'reqMethodName': 'core.users.search',
'lId': 'suggestLoader',
'hlr': 'true',
'iMinLen': 1,
'stCols': 2,
'stColsClass': [
'cleft', 'cright'
],
'stColsHLR': [true, false]
});
}
// Init system [ IE / Other browsers should be inited in different ways ]
if (document.body.attachEvent) { // IE
document.body.onload = systemInit;
} else { // Others
systemInit();
} filter_attach_DateEdit('dr1');
filter_attach_DateEdit('dr2');
	-->
</script>
