fuc/storage/framework/smarty/compile/7b3ebf4bd8e8ed52f2ff9227ceabff7f42ff3119_0.file_coupon.tpl.php
2025-03-13 17:13:42 +08:00

305 lines
12 KiB
PHP
Executable File

<?php
/* Smarty version 5.3.1, created on 2025-02-02 11:45:13
from 'file:admin/coupon.tpl' */
/* @var \Smarty\Template $_smarty_tpl */
if ($_smarty_tpl->getCompiled()->isFresh($_smarty_tpl, array (
'version' => '5.3.1',
'unifunc' => 'content_679eea49a9a735_46951663',
'has_nocache_code' => false,
'file_dependency' =>
array (
'7b3ebf4bd8e8ed52f2ff9227ceabff7f42ff3119' =>
array (
0 => 'admin/coupon.tpl',
1 => 1712762115,
2 => 'file',
),
),
'includes' =>
array (
'file:admin/header.tpl' => 1,
'file:datatable.tpl' => 1,
'file:admin/footer.tpl' => 1,
),
))) {
function content_679eea49a9a735_46951663 (\Smarty\Template $_smarty_tpl) {
$_smarty_current_dir = '/www/wwwroot/fuuu.cloud/resources/views/tabler/admin';
$_smarty_tpl->renderSubTemplate('file:admin/header.tpl', $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, $_smarty_tpl->cache_lifetime, array(), (int) 0, $_smarty_current_dir);
?>
<link rel="stylesheet" href="//<?php echo $_smarty_tpl->getValue('config')['jsdelivr_url'];?>
/npm/flatpickr/dist/flatpickr.min.css">
<?php if ($_smarty_tpl->getValue('user')->is_dark_mode) {?>
<link rel="stylesheet" href="//<?php echo $_smarty_tpl->getValue('config')['jsdelivr_url'];?>
/npm/flatpickr/dist/themes/dark.min.css">
<?php }
echo '<script'; ?>
src="//<?php echo $_smarty_tpl->getValue('config')['jsdelivr_url'];?>
/npm/flatpickr"><?php echo '</script'; ?>
>
<?php echo '<script'; ?>
src="//<?php echo $_smarty_tpl->getValue('config')['jsdelivr_url'];?>
/npm/flatpickr/dist/l10n/zh.js"><?php echo '</script'; ?>
>
<div class="page-wrapper">
<div class="container-xl">
<div class="page-header d-print-none text-white">
<div class="row align-items-center">
<div class="col">
<h2 class="page-title">
<span class="home-title">优惠码</span>
</h2>
<div class="page-pretitle my-3">
<span class="home-subtitle">
查看并管理优惠码
</span>
</div>
</div>
<div class="col-auto">
<div class="btn-list">
<a href="#" class="btn btn-primary" data-bs-toggle="modal"
data-bs-target="#create-dialog">
<i class="icon ti ti-plus"></i>
创建
</a>
</div>
</div>
</div>
</div>
</div>
<div class="page-body">
<div class="container-xl">
<div class="row row-deck row-cards">
<div class="col-12">
<div class="card">
<div class="table-responsive">
<table id="data-table" class="table card-table table-vcenter text-nowrap datatable">
<thead>
<tr>
<?php
$_from = $_smarty_tpl->getSmarty()->getRuntime('Foreach')->init($_smarty_tpl, $_smarty_tpl->getValue('details')['field'], 'value', false, 'key');
$foreach0DoElse = true;
foreach ($_from ?? [] as $_smarty_tpl->getVariable('key')->value => $_smarty_tpl->getVariable('value')->value) {
$foreach0DoElse = false;
?>
<th><?php echo $_smarty_tpl->getValue('value');?>
</th>
<?php
}
$_smarty_tpl->getSmarty()->getRuntime('Foreach')->restore($_smarty_tpl, 1);?>
</tr>
</thead>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="modal modal-blur fade" id="create-dialog" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered modal-dialog-scrollable" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">优惠码内容</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<?php
$_from = $_smarty_tpl->getSmarty()->getRuntime('Foreach')->init($_smarty_tpl, $_smarty_tpl->getValue('details')['create_dialog'], 'detail');
$foreach1DoElse = true;
foreach ($_from ?? [] as $_smarty_tpl->getVariable('detail')->value) {
$foreach1DoElse = false;
?>
<?php if ($_smarty_tpl->getValue('detail')['type'] === 'input') {?>
<div class="form-group mb-3 row">
<label class="form-label col-3 col-form-label"><?php echo $_smarty_tpl->getValue('detail')['info'];?>
</label>
<div class="col">
<input id="<?php echo $_smarty_tpl->getValue('detail')['id'];?>
" type="text" class="form-control"
placeholder="<?php echo $_smarty_tpl->getValue('detail')['placeholder'];?>
">
</div>
</div>
<?php }?>
<?php if ($_smarty_tpl->getValue('detail')['type'] === 'textarea') {?>
<div class="form-group mb-3 row">
<label class="form-label col-3 col-form-label"><?php echo $_smarty_tpl->getValue('detail')['info'];?>
</label>
<textarea id="<?php echo $_smarty_tpl->getValue('detail')['id'];?>
" class="col form-control" rows="<?php echo $_smarty_tpl->getValue('detail')['rows'];?>
"
placeholder="<?php echo $_smarty_tpl->getValue('detail')['placeholder'];?>
"></textarea>
</div>
<?php }?>
<?php if ($_smarty_tpl->getValue('detail')['type'] === 'select') {?>
<div class="form-group mb-3 row">
<label class="form-label col-3 col-form-label"><?php echo $_smarty_tpl->getValue('detail')['info'];?>
</label>
<div class="col">
<select id="<?php echo $_smarty_tpl->getValue('detail')['id'];?>
" class="col form-select">
<?php
$_from = $_smarty_tpl->getSmarty()->getRuntime('Foreach')->init($_smarty_tpl, $_smarty_tpl->getValue('detail')['select'], 'value', false, 'key');
$foreach2DoElse = true;
foreach ($_from ?? [] as $_smarty_tpl->getVariable('key')->value => $_smarty_tpl->getVariable('value')->value) {
$foreach2DoElse = false;
?>
<option value="<?php echo $_smarty_tpl->getValue('key');?>
"><?php echo $_smarty_tpl->getValue('value');?>
</option>
<?php
}
$_smarty_tpl->getSmarty()->getRuntime('Foreach')->restore($_smarty_tpl, 1);?>
</select>
</div>
</div>
<?php }?>
<?php
}
$_smarty_tpl->getSmarty()->getRuntime('Foreach')->restore($_smarty_tpl, 1);?>
<div class="form-group mb-3 row">
<label class="form-label col-3 col-form-label">过期时间(留空则为不限制)</label>
<div class="col">
<input id="expire_time" type="text" class="form-control"
placeholder="">
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn me-auto" data-bs-dismiss="modal">取消</button>
<button id="create-button" onclick="createCoupon()"
type="button" class="btn btn-primary" data-bs-dismiss="modal">创建
</button>
</div>
</div>
</div>
</div>
<?php $_smarty_tpl->renderSubTemplate('file:datatable.tpl', $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, $_smarty_tpl->cache_lifetime, array(), (int) 0, $_smarty_current_dir);
?>
<?php echo '<script'; ?>
>
flatpickr("#expire_time", {
enableTime: true,
dateFormat: "U",
time_24hr: true,
minDate: "today",
locale: "zh"
});
tableConfig.ajax = {
url: '/admin/coupon/ajax',
type: 'POST',
dataSrc: 'coupons'
};
tableConfig.order = [
[1, 'desc']
];
tableConfig.columnDefs = [
{
targets: [0],
orderable: false
}
];
let table = new DataTable('#data-table', tableConfig);
function loadTable() {
table;
}
function createCoupon() {
$.ajax({
url: '/admin/coupon',
type: 'POST',
dataType: "json",
data: {
<?php
$_from = $_smarty_tpl->getSmarty()->getRuntime('Foreach')->init($_smarty_tpl, $_smarty_tpl->getValue('details')['create_dialog'], 'detail');
$foreach3DoElse = true;
foreach ($_from ?? [] as $_smarty_tpl->getVariable('detail')->value) {
$foreach3DoElse = false;
?>
<?php echo $_smarty_tpl->getValue('detail')['id'];?>
: $('#<?php echo $_smarty_tpl->getValue('detail')['id'];?>
').val(),
<?php
}
$_smarty_tpl->getSmarty()->getRuntime('Foreach')->restore($_smarty_tpl, 1);?>
expire_time: $('#expire_time').val(),
},
success: function (data) {
if (data.ret === 1) {
$('#success-noreload-message').text(data.msg);
$('#success-noreload-dialog').modal('show');
reloadTableAjax();
} else {
$('#fail-message').text(data.msg);
$('#fail-dialog').modal('show');
}
}
})
}
function deleteCoupon(coupon_id) {
$('#notice-message').text('确定删除此优惠码?');
$('#notice-dialog').modal('show');
$('#notice-confirm').off('click').on('click', function () {
$.ajax({
url: "/admin/coupon/" + coupon_id,
type: 'DELETE',
dataType: "json",
success: function (data) {
if (data.ret === 1) {
$('#success-noreload-message').text(data.msg);
$('#success-noreload-dialog').modal('show');
reloadTableAjax();
} else {
$('#fail-message').text(data.msg);
$('#fail-dialog').modal('show');
}
}
})
});
}
function disableCoupon(coupon_id) {
$('#notice-message').text('确定禁用此优惠码?');
$('#notice-dialog').modal('show');
$('#notice-confirm').off('click').on('click', function () {
$.ajax({
url: "/admin/coupon/" + coupon_id + "/disable",
type: 'POST',
dataType: "json",
success: function (data) {
if (data.ret === 1) {
$('#success-noreload-dialog').text(data.msg);
$('#success-noreload-message').modal('show');
reloadTableAjax();
} else {
$('#fail-message').text(data.msg);
$('#fail-dialog').modal('show');
}
}
})
});
}
function reloadTableAjax() {
table.ajax.reload(null, false);
}
loadTable();
<?php echo '</script'; ?>
>
<?php $_smarty_tpl->renderSubTemplate('file:admin/footer.tpl', $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, $_smarty_tpl->cache_lifetime, array(), (int) 0, $_smarty_current_dir);
}
}