Просмотр файла account/eshop_units.php

Размер файла: 6.01Kb
<?php
$page_name = 'Управление экземплярами';
$page_keys = 'Управление экземплярами';
$page_desc = 'Управление экземплярами';
$online_title = 'На странице управления экземплярами';
$online_url = '/account/';
$page_right = '<div class="header-buttons"><div class="collapse" id="header-buttons"><div class="well"><div class="btn-group"><a data-toggle="modal" role="button" href="#newu" class="btn btn-primary">Новый экземпляр</a></div></div></div></div>';
$prevurl_1 = '/account/eshop_my';
$prevname_1 = 'Мои товары';
include('../wu-engine/wu_header.php');
if(!USER_LOGGED) { header ("Location: /"); exit; }

$getid = intval($_GET['id']);
$maths = mysqli_query($connect_db, "SELECT id FROM `".DB_PREFIX."_es` WHERE id='$getid' AND usr = '$u_id'");
$how = mysqli_num_rows($maths);
if ($how > 0) {
?>

<?php
$page = intval($_GET['page']);
$num = 20;
if ($page==0) $page=1;
$qu = mysqli_fetch_assoc(mysqli_query($connect_db, "SELECT count(`id`) AS `cnt` FROM ".DB_PREFIX."_es_u WHERE m = '$getid'"));
$co = $qu['cnt'];
$total = intval(($co - 1) / $num) + 1;
$page = intval($page);
if(empty($page) or $page < 0) $page = 1;
if($page > $total) $page = $total;
$start = $page * $num - $num;
if ($page != 1) $pervpage = '<li><a href="/account/eshop_units?page='. ($page - 1).'">Предыдущая страница</a></li>';
if ($page != $total) $nextpage = '<li><a href="/account/eshop_units?page='. ($page + 1).'">Следующая страница</a></li>';
$qr = mysqli_query($connect_db, "SELECT id,st,sec FROM ".DB_PREFIX."_es_u WHERE m='$getid' ORDER BY id DESC LIMIT $start, $num");
if ($co > 0) {
while($row = mysqli_fetch_array($qr)) {
?>
<div class="panel panel-default">
<div class="panel-heading">
<h6 class="panel-title">Экземпляр #<?php echo $row['id']; ?></h6>
<div class="panel-icons-group">
<?php if ($row['st'] == 0) { ?><a href="javascript://" class="btn btn-link btn-icon tip" data-placement="bottom" data-original-title="Продаётся"><i class="icon-file-plus"></i></a><?php }
if ($row['st'] == 1) { ?><a href="javascript://" class="btn btn-link btn-icon tip" data-placement="bottom" data-original-title="Продан"><i class="icon-file-remove"></i></a><?php } ?>
<a href="javascript://" id="bdel_<?php echo $row['id']; ?>" onclick="rdel('<?php echo $row['id']; ?>');" class="btn btn-link btn-icon tip" data-placement="bottom" data-original-title="Удалить"><i class="icon-remove2"></i></a>
</div>
</div>
<div class="panel-body">
<div class="media">
<div class="media-body cpn marnone">
<?php echo nl2br(htmlspecialchars($row['sec'])); ?>
</div>
</div>
</div>
</div>
<?php }
if ($total>1) { echo '<ul class="pager">'.$pervpage.$nextpage.'</ul>'; } ?>
<div id="rdelete" class="modal fade" tabindex="-1" role="dialog">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title"><i class="icon-remove"></i> Удаление экземпляра #<font id="todel"></font></h4>
</div>
<div class="modal-body with-padding">
<div class="alert alert-danger fade in"><center>Восстановить экземпляр будет нельзя</center></div>
</div>
<div class="modal-footer">
<a class="btn btn-danger" href="javascript://" id="rdel" data-loading-text="<i class='icon-spinner7 spin'></i> Удаляем">Удалить</a>
<button class="btn btn-warning" data-dismiss="modal">Отмена</button>
</div>
</div>
</div>
</div>
<?php } else { echo '<div class="alert alert-info fade in"><i class="icon-info"></i> Вы пока не добавляли экземпляры</div>'; } ?>
<div id="newu" class="modal fade" tabindex="-1" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title"><i class="icon-plus"></i> Новый экземпляр</h4>
</div>
<div class="modal-body with-padding">
<div class="form-group">
<label>Введите текст экземпляра:</label>
<textarea class="form-control" placeholder="Текст экземпляра" id="sec"></textarea>
</div>
</div>
<div class="modal-footer">
<a class="btn btn-success" href="javascript://" id="uadd" data-loading-text="<i class='icon-spinner7 spin'></i> Добавляем">Добавить</a>
<button class="btn btn-warning" data-dismiss="modal">Отмена</button>
</div>
</div>
</div>
</div>
<script type='text/javascript'>
var vrdel;
function rdel(id){
vrdel = id;
$('#todel').text(id);
$('#rdelete').modal('show');
};
$(function() {
var btnr = $('#rdel');
btnr.click(function(){
btnr.button('loading');
$.ajax({
type: 'POST',
url: '/wu-engine/wu-actions/eshop_unit_del.php',
data: {'id': vrdel, 'token': token},
cache: false,
success: function(result){
btnr.button('reset');
if (result == '0') {
$.jGrowl('Данный экземпляр нельзя удалить', { theme: 'growl-error' });
}
if (result == '1') {
$(location).attr('href','/account/eshop_units/<?php echo $getid; ?>');
}
if (result == '3') {
jerr();
}
},
error: function(){
btnr.button('reset');
serr();
}
});
});
var btns = $('#uadd');
btns.click(function(){
btns.button('loading');
var sec = $('#sec').val();
$.ajax({
type: 'POST',
url: '/wu-engine/wu-actions/eshop_unit_new.php',
data: {'id': '<?php echo $getid; ?>', 'sec': sec, 'token': token},
cache: false,
success: function(result){
btns.button('reset');
if (result == '0') {
$.jGrowl('Вы не ввели текст экземпляра', { theme: 'growl-error' });
}
if (result == '1') {
$(location).attr('href','/account/eshop_units/<?php echo $getid; ?>');
}
if (result == '3') {
jerr();
}
},
error: function(){
btns.button('reset');
serr();
}
});
});
});
</script>
<?php
} else { echo '<div class="alert alert-danger fade in"><i class="icon-warning"></i> У Вас нет такого товара</div>'; }
?>

<?php include('../wu-engine/wu_footer.php'); ?>