<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="Поиск по заданию" <?php if(!empty($filtr['TaskId'])) echo "value=\"{$filtr['TaskId']}\""; ?> name="TaskId" 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>
<?php
if($_POST['okbantaskid']){
$db = new db(dbHost, dbUser, dbPass, dbName);
$okbantaskid = $_POST['okbantaskid'];
$thisreport = $db->query("SELECT * FROM `mod_task_user` WHERE `Id`='$okbantaskid'")->fetchArray();
$status = $thisreport['Status'];
if(($status == 3) or ($status == 7) or ($status == 6)){
$amount = $thisreport['Amount'];
$uidreport = $thisreport['UserId'];
$taskid = $thisreport['TaskId'];
$db->query("UPDATE `mod_task` SET `Balans`=`Balans`-'$amount' WHERE `Id`='$taskid'");
$db->query("UPDATE `mod_task_user` SET `Status`='4' WHERE `Id`='$okbantaskid'");
$db->query("UPDATE `db_users` SET `money_p`=`money_p`+'$amount' WHERE `id`='$uidreport'");
echo '<div class="alert alert-success"><strong>Успех</strong></div>';
}
else{
echo '<div class="alert alert-warning"><strong>Ошибка #$status '.$thisreport['Status'].' '.$thisreport['Amount'].' '.$okbantaskid.'</strong></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 onclick="return sortitem('TaskId',this);" class="btn-link btn_sort">Задание <?php if($sort == 'TaskId') echo '<i class="fa fa-caret-down"></i>'; elseif($sort == 'TaskId DESC') echo '<i class="fa fa-caret-up"></i>'; ?></button></th>
<th><button style="font-size: 12px;" onclick="return sortitem('Status',this);" class="btn-link btn_sort">Статус <?php if($sort == 'Status') echo '<i class="fa fa-caret-down"></i>'; elseif($sort == 'Status 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><button style="font-size: 12px;" onclick="return sortitem('AddDate',this);" class="btn-link btn_sort">Начало <?php if($sort == 'AddDate') echo '<i class="fa fa-caret-down"></i>'; elseif($sort == 'AddDate DESC') echo '<i class="fa fa-caret-up"></i>'; ?></button></th>
<th><button style="font-size: 12px;" onclick="return sortitem('EndDate',this);" class="btn-link btn_sort">Окончание <?php if($sort == 'EndDate') echo '<i class="fa fa-caret-down"></i>'; elseif($sort == 'EndDate DESC') echo '<i class="fa fa-caret-up"></i>'; ?></button></th>
<th></th>
</tr>
</thead>
<tbody>
<?php foreach($items->data as $val){
$classstaus = $trclass = '';
$ts = (int)$val['Status'];
if($ts === 1){
//$trclass = "success";
$classstaus = 'text-success';
}
elseif($ts === 2){
$trclass = "warning";
$classstaus = 'text-warning';
}
elseif($ts === 3 || $ts === 7){
$trclass = "danger";
$classstaus = 'text-danger';
}
else
$classstaus = 'text-muted';
$_url = (mb_strlen($val['Url']) > 40) ? (mb_substr($val['Url'], 0, 40).' ...') : $val['Url'];
?>
<tr class="<?php echo $trclass; ?>">
<td style="max-width: 100px;">
<?php echo $val['Id']; ?><br />
<?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>
<?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> <button onclick="items_filtr_userid(<?php echo $val['UserId']; ?>)" class="btn btn-xs"><i class="fa fa-search"></i></button>
<?php } ?>
</td>
<td>
<strong><?php echo $val['Title']; ?></strong>
<div>
<a href="<?php echo $task_url.'?Id='.$val['TaskId']; ?>">Задание №<?php echo $val['TaskId']; ?></a>
</div>
</td>
<td style="text-align: center;" class="<?php echo $classstaus; ?>">
<strong><?php echo $r_m->status[$ts]; ?></strong>
<?php if($ts === 4) { $val['Rat'] = (int)$val['Rat']; ?>
<?php if($val['Rat'] === 0){ ?>
<div class="form-group">
<form method="post" style="text-align: center;">
<input type="hidden" name="RatOk" value="<?php echo $val['Id']; ?>" />
<button class="btn btn-xs btn-success" type="submit" name="Rat" value="1"><i class="fa fa-plus"></i></button>
<button class="btn btn-xs btn-warning" type="submit" name="Rat" value="0"><i class="fa fa-minus"></i></button>
</form>
</div>
<?php } else { ?>
<div style="font-size: 13px; color:#000;"><strong>Оценка:</strong> <?php echo ($val['Rat'] === 1) ? '<label class="text-success"><i class="fa fa-plus"></i></label>' : '<label class="text-danger"><i class="fa fa-minus"></i></label>'; ?></div>
<?php } ?>
<?php } ?>
</td>
<td>
<?php echo $val['Amount'].' руб.'; ?>
</td>
<td><?php echo date('d.m.Y', $val['AddDate']); ?><br /><?php echo date('H:i', $val['AddDate']); ?></td>
<td><?php echo date('d.m.Y', $val['EndDate']); ?><br /><?php echo date('H:i', $val['EndDate']); ?></td>
<td style="width: 90px;">
<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>
<?php if($ts < 4){
?><button style="margin:3px;" title="Блокировать" data-toggle="tooltip" data-placement="bottom" class="btn btn-sm btn-danger" onclick="return blok_item(<?php echo $val['Id']; ?>);"><i class="fa fa-minus-circle"></i></button><?php
}
elseif($classstaus=='text-danger'){
?><form method="post" style="display: inline;"><input type="hidden" name="okbantaskid" value="<?php echo $val['Id']; ?>"><button type="submit" style="margin: 3px; color: #fff; background-color: #5dc92c; border-color: #5cac25;" title="Оплатить" data-toggle="tooltip" data-placement="bottom" class="btn btn-sm"><i class="fa fa-check"></i></button></form><?php
}
?>
</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);"><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 items_filtr_userid(id){
$('[name=UserId]').val(id);
return items_filtr();
}
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){
if(!$('#app_comm_show').is(':visible')){
$('#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(){
//$([chosen]).chosen("destroy");
$('.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);
//$("[chosen]").chosen({no_results_text: "Значение не найдено!"});
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 blok_item(id){
if(!confirm('Заблокировать и вернуть деньги?'))
return false;
var formData = getFormData_el('[data-dataform]');
formData.append('blok',id);
dataload(formData);
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;
}
</script>