<?php global $adm; ?>
<div>
<div id="mav_load">
<h1>Задания</h1>
<div class="feedok"><?php echo $feed; ?></div>
<div class="items_filtr">
<div class="col-sm-6">
<div class="form-group">
<label>Поисковая фраза:</label>
<input data-dataform="" type="text" placeholder="Поиск по заголовку или URL-адресу" <?php if(!empty($filtr['s'])) echo "value=\"{$filtr['s']}\""; ?> name="s" class="form-control input-sm" />
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<label>Статус:</label><br />
<select class="form-control" name="Approved" data-dataform="">
<option <?php if(!isset($filtr['Approved'])) echo 'selected="selected"'; ?> value="">Любой ...</option>
<option <?php if(isset($filtr['Approved']) && $filtr['Approved'] < 0) echo 'selected="selected"'; ?> value="-1">Отклонен</option>
<option <?php if(isset($filtr['Approved']) && $filtr['Approved'] == 0) echo 'selected="selected"'; ?> value="0">На проверке</option>
<option <?php if(isset($filtr['Approved']) && $filtr['Approved'] > 0) echo 'selected="selected"'; ?> value="1">Одобрен</option>
</select>
</div>
</div>
<div class="clearfix"></div>
<div class="col-sm-6">
<div class="form-group">
<label>Поиск по ИД-пользователя:</label>
<input data-dataform="" type="text" placeholder="Поиск по ИД-пользователя" <?php if(!empty($filtr['UserId'])) echo "value=\"{$filtr['UserId']}\""; ?> name="UserId" class="form-control input-sm" />
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<label>Поиск по ИД:</label>
<input data-dataform="" type="text" placeholder="Поиск по ИД" <?php if(!empty($filtr['Id'])) echo "value=\"{$filtr['Id']}\""; ?> name="Id" class="form-control input-sm" />
</div>
</div>
<input type="hidden" id="startpag" data-dataform="" name="startpag" value="<?php echo $startpag; ?>">
<input type="hidden" id="sort" data-dataform="" name="sort" value="<?php echo $sort; ?>">
<input type="hidden" id="url_build" name="url_build" value="<?php echo $url_build; ?>">
<div class="clearfix"></div>
<p style="text-align: center;">
<button type="button" class="btn btn-default" onclick="items_filtr();"><i class="fa fa-filter"></i> Поехали</button>
<button type="button" class="btn btn-default" onclick="items_filtr_clear();"><i class="fa fa-times"></i> Очистить</button>
</p>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Список заданий</h3>
</div>
<?php if(empty($items) || empty($items->data)) { ?>
<div class="panel-body" style="text-align: center;">
<em>Нет заданий</em>
</div>
<?php } else { ?>
<div class="table-responsive">
<table class="table table-striped table-hover table-condensed">
<thead>
<tr>
<th><button onclick="return sortitem('Id',this);" class="btn-link btn_sort">№ <?php if($sort == 'Id') echo '<i class="fa fa-caret-down"></i>'; elseif($sort == 'Id DESC') echo '<i class="fa fa-caret-up"></i>'; ?></button></th>
<th><button style="text-align: center;white-space: nowrap;font-size: 12px;font-weight: normal;" onclick="return sortitem('B_type',this);" class="btn-link btn_sort">Пользователь <?php if($sort == 'B_type') echo '<i class="fa fa-caret-down"></i>'; elseif($sort == 'B_type DESC') echo '<i class="fa fa-caret-up"></i>'; ?></button></th>
<th><button onclick="return sortitem('Url',this);" class="btn-link btn_sort">URL <?php if($sort == 'Url') echo '<i class="fa fa-caret-down"></i>'; elseif($sort == 'Url DESC') echo '<i class="fa fa-caret-up"></i>'; ?></button></th>
<th style="text-align: center;">Статус</th>
<th><button style="font-size: 12px;" onclick="return sortitem('Balans',this);" class="btn-link btn_sort">Баланс <?php if($sort == 'Balans') echo '<i class="fa fa-caret-down"></i>'; elseif($sort == 'Balans DESC') echo '<i class="fa fa-caret-up"></i>'; ?></button></th>
<th><button style="font-size: 12px;" onclick="return sortitem('Amount',this);" class="btn-link btn_sort">Оплата <?php if($sort == 'Amount') echo '<i class="fa fa-caret-down"></i>'; elseif($sort == 'Amount DESC') echo '<i class="fa fa-caret-up"></i>'; ?></button></th>
<th>Статистика</th>
<th></th>
</tr>
</thead>
<tbody>
<?php foreach($items->data as $val){
$tr_class = '';
$val['Approved'] = (int)$val['Approved'];
if($val['Approved'] < 0)
$tr_class = 'class="danger"';
elseif($val['Approved'] < 1)
$tr_class = 'class="warning"';
$_url = (mb_strlen($val['Url']) > 40) ? (mb_substr($val['Url'], 0, 40).' ...') : $val['Url'];
?>
<tr <?php echo $tr_class; ?> id="ord_tr<?php echo $val['Id']; ?>">
<td style="max-width: 100px;"><?php echo $val['Id']; ?></td>
<td>
<?php if($val['Blok'] > 0){ ?>
<button onclick="return blok_del(<?php echo $val['UserId']; ?>);" title="Разблокировать" data-toggle="tooltip" class="btn btn-xs btn-default"><i class="fa fa-check"></i></button> <del class="text-muted"><?php echo $val['Login']; ?></del></strong> (<small><a title="Перейти на страницу пользователя" href="<?= '/'.$adm.'/users/info/'.$val['UserId']; ?>">ИД <?php echo $val['UserId']; ?></a></small>)
<?php } else { ?>
<button onclick="return blok_add(<?php echo $val['UserId']; ?>);" title="Заблокировать пользователю доступ к разделу" data-toggle="tooltip" class="btn btn-xs btn-danger"><i class="fa fa-times"></i></button> <?php echo $val['Login']; ?></strong> (<small><a title="Перейти на страницу пользователя" href="<?= '/'.$adm.'/users/info/'.$val['UserId']; ?>">ИД <?php echo $val['UserId']; ?></a></small>)
<?php } ?>
</td>
<td>
<strong><?php echo $val['Title']; ?></strong>
<div style="font-size: 12px;">
<span class="text-success"><i title="Категория" data-toggle="tooltip" class="fa fa-bars"></i> <strong><?php echo $val['CatTitle']; ?></strong></span><br />
<a title="Проверка на вирусы Яндекс" class="btn btn-default btn-xs" target="_blank" href="https://yandex.ru/infected?url=<?php echo urlencode($val['Url']); ?>"><i class="fa fa-yoast"></i></a> <a title="Проверка на вирусы Google" class="btn btn-default btn-xs" target="_blank" href="https://transparencyreport.google.com/safe-browsing/search?url=<?php echo urlencode($val['Url']); ?>"><i class="fa fa-google"></i></a>
<span class="text-muted"><i title="Url-адрес задания" data-toggle="tooltip" class="fa fa-globe"></i> <span title="<?php echo $val['Url']; ?>"><?php echo $_url; ?></span></span>
</div>
</td>
<td style="text-align: center;">
<select onchange="approved_change(<?php echo $val['Id']; ?>,this);" class="form-control">
<option value="-1" <?php if($val['Approved'] < 0) echo 'selected="selected"'; ?>>Отклонено</option>
<option value="0" <?php if($val['Approved'] === 0) echo 'selected="selected"'; ?>>На проверке</option>
<option value="1" <?php if($val['Approved'] > 0) echo 'selected="selected"'; ?>>Одобрено</option>
</select>
<?php if($val['Approved'] < 0) { ?>
<button onclick="app_comm_show(<?php echo $val['Id']; ?>,1);" class="btn btn-xs btn-default">Указать причину</button>
<div id="app_comm_pos_<?php echo $val['Id']; ?>"></div>
<input type="hidden" id="app_comm_<?php echo $val['Id']; ?>" value="<?php echo $val['ApprovedComm']; ?>" />
<?php } ?>
<div style="margin-top: 5px;">
<?php
if($val['Approved'] < 0) echo '<span style="color: red; font-size:12px;"><i class="fa fa-times"></i> Отклонено модератором</span>';
elseif($val['Approved'] < 1) echo '<span style="color: #8a6d3b;"><i class="fa fa-exclamation-triangle"></i> На проверке</span>';
elseif($val['Active'] < 1) echo '<span style="color: red; font-size:12px;"><i class="fa fa-times"></i> Показы остановленны</span>';
else { ?>
<span style="color: green; font-size:12px;"><i class="fa fa-check"></i> Идут показы</span>
<?php } ?>
</div>
</td>
<td>
<?php echo $val['Balans'].' руб.'; ?>
</td>
<td>
<?php echo $val['Amount'].' руб.'; ?>
</td>
<td>
Выполн.: <?php echo $val['st1']; ?> / <?php echo $val['st4']; ?><br />
Оценки :<span class="text-success">+<?php echo $val['RatPlus']; ?></span> / <span class="text-danger">-<?php echo $val['RatMinus']; ?></span>
</td>
<td style="width: 90px;">
<a style="margin:3px;" title="Исполнители" data-toggle="tooltip" data-placement="bottom" class="btn btn-sm btn-warning" href="/<?php echo $adm; ?>/mav_task/user?TaskId=<?php echo $val['Id']; ?>" target="_blank"><i class="fa fa-users"></i></a>
<button style="margin:3px;" title="Редактировать" data-toggle="tooltip" data-placement="bottom" class="btn btn-sm btn-warning" onclick="show_item(<?php echo $val['Id']; ?>);"><i class="fa fa-pencil"></i></button>
<button style="margin:3px;" title="Удалить" data-toggle="tooltip" data-placement="bottom" class="btn btn-sm btn-danger" onclick="return delet_item(<?php echo $val['Id']; ?>);"><i class="fa fa-trash"></i></button>
</td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
<?php echo $pager; ?>
<?php } ?>
</div>
<div class="mymod-overlay imem_mod" id="blok_add">
<div class="mymod-table">
<div class="mymod-cell">
<div class="mymod-modal" style="min-width: 40%;">
<a href="#close" onclick="return mymod();" class="mymod-close"></a>
<h2>Заблокировать пользователя</h2>
<div class="form-group">
<label>Пользователь</label>
<input class="form-control" type="text" readonly="readonly" id="blok_add_id" />
</div>
<div class="form-group">
<label>Причина блокировки:</label>
<textarea rows="2" id="blok_add_comm" class="form-control"></textarea>
</div>
<p><button class="btn btn-danger" onclick="_blok_add();">Заблокировать</button></p>
</div>
</div>
</div>
</div>
<div id="app_comm_show" style="position: absolute;display: none;top: 0;left: 0;">
<div class="comm_edit_form" style="display: block;">
<textarea id="app_comm_show_text" style="margin:5px 0;width: 100%;" rows="3"><?php echo $val['ApprovedComm']; ?></textarea>
<input type="hidden" id="app_comm_show_id" />
<button class="btn btn-sm btn-default" onclick="app_comm_show(this,0);"><i class="fa fa-times"></i></button>
<button class="btn btn-sm btn-danger" onclick="comm_change();"><i class="fa fa-pencil"></i> Сохранить</button>
</div>
</div>
<div id="show_item"></div>
</div>
</div>
<script src="/assets/mav/js/start.js"></script>
<script>
function blok_add(id){
$('#blok_add_id').val(id);
$('#blok_add').fadeIn(300);
return false;
}
function _blok_add(){
var formData = getFormData_el('[data-dataform]');
formData.append('Blok_add',$('#blok_add_id').val());
formData.append('Comm',$('#blok_add_comm').val());
dataload(formData);
return false;
}
function blok_del(id,st){
var formData = getFormData_el('[data-dataform]');
formData.append('Blok_del',id);
dataload(formData);
return false;
}
function app_comm_show(id,p){
if(p){
$('#app_comm_show').offset($('#app_comm_pos_'+id).offset());
$('#app_comm_show #app_comm_show_text').val($('#app_comm_'+id).val());
$('#app_comm_show').css('display','block');
$('#app_comm_show_id').val(id);
}
else{
$('#app_comm_show').offset({top:0,left:0});
$('#app_comm_show').css('display','none');
}
}
function show_item(id){
$('#ajaxProgress').show();
$('#show_item').load(document.location.href,{show_item:id,aj:1},function(){$('#ajaxProgress').hide();});
return false;
}
function items_filtr(){
$('#startpag').val(1);
var formData = getFormData_el('[data-dataform]');
dataload(formData);
return false;
}
function items_filtr_clear(){
$('.items_filtr select option').removeAttr('selected');
$('.items_filtr select option:first-child').attr('selected','selected');
//$('.items_filtr select option').prop('selected',false);
$(".items_filtr input[type=text]").val('');
$('.items_filtr input[type=checkbox]').removeAttr('checked');
//$('.items_filtr input[type=checkbox]').prop('checked',false);
return items_filtr();
}
function pager(pag){
$('#startpag').val(pag);
var formData = getFormData_el('[data-dataform]');
dataload(formData);
return false;
}
function sortitem(el,e){
$('.btn_sort').find('.fa').remove();
if($('#sort').val() == el)
el += ' DESC';
$('#sort').val(el);
items_filtr();
return false;
}
function dataload(formData){
$('#ajaxProgress').show();
formData.append('aj',1);
$.ajax({
url: document.location.href,
type: "POST",
cache: false,
contentType: false,
processData: false,
data: formData,
success: function(content){
$('#mav_load').html($(content).find('#mav_load').html());
$('#ajaxProgress').hide();
window.history.pushState(null, null, $('#url_build').val());
}
});
return false;
}
function approved_change(id,st){
var formData = getFormData_el('[data-dataform]');
formData.append('Approved_up',$(st).val());
formData.append('ItemId',id);
dataload(formData);
return false;
}
function comm_change(id){
var formData = getFormData_el('[data-dataform]');
formData.append('Kom_up',$('#app_comm_show_text').val());
formData.append('ItemId',$('#app_comm_show_id').val());
dataload(formData);
return false;
}
function delet_item(id){
if(!confirm('Подтвердите удаление!'))
return false;
var formData = getFormData_el('[data-dataform]');
formData.append('DeletItem',id);
dataload(formData);
return false;
}
</script>