<?php
error_reporting(0); 
include("../../config/ht.php");
session_start();
if(!isset($_SESSION['adminname'])){echo "<script>alert('请重新登录!')</script><script>top.location.href='/$htlj/'</script>";exit;}
$adminname=$_SESSION['adminname'];
$type="where name='$adminname'";
$adminpd=queryall(admin,$type);
if(!$adminpd){echo "<script>alert('请重新登录!')</script><script>top.location.href='/$htlj/'</script>";exit;}
if($adminpd[qx]=='超级管理员'){}else{echo "<script>alert('无权限')</script><script>top.location.href='/$htlj/'</script>";exit;}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="gb2312">
<title>支付通道列表</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="stylesheet" href="/layui/css/houtai.css" media="all" />
<link rel="stylesheet" href="/2019newui/houtai/css/font-awesome.min.css" media="all" />
<link rel="stylesheet" href="/2019newui/houtai/css/admin.css" media="all">
<link rel="stylesheet" href="/2019newui/houtai/css/peizhi.css" media="all">
<script src="/2019newui/js/jquery.min.js"></script>
<script src="/layui/layui.js"></script>
<script src="/2019newui/js/bootstrap.min.js"></script>
<style type="text/css">
#tooltip{position:absolute;border:1px solid #ccc;background:#333;padding:2px;display:none;color:#fff;}
</style>
</head>
<body style="padding:10px;">
<div class="tplay-body-div">
<fieldset class="layui-elem-field layui-field-title" style="margin-top:20px;"><legend>支付通道列表</legend></fieldset>
<div class="layui-tab layui-tab-brief">
<div class="layui-tab-content">
<div class="layui-form-item">
<div class="layui-inline">
<a class="layui-btn layui-btn-normal addNews_btn pub_btn" data-toggle="modal" data-target="#myPublic2">添加支付通道</a>
</div>
</div>
</div> 
<table class="layui-table">
<thead>
<tr>
<th style="text-align:center;">ID</th>
<th style="text-align:center; ">主通道</th>
<th style="text-align:center;" >通道名称</th>
<th style="text-align:center;" >通道标识</th>
<th style="text-align:center;" >添加配置</th>
<th style="text-align:center;" >是人是鬼</th>
<th style="text-align:center;">操作</th>
</tr>
</thead>
<tbody>
<?php 
$resultyttrt = mysql_query("select id from hzpay");
$count = mysql_num_rows($resultyttrt); 
?>
<?php if($count == 0){?>
<tr><td  colspan=18  style="text-align:center;"><center>没有记录</center></td></tr>
<?php }?>
<?php 
$query = mysql_query("select * from  hzpay");
while ($a=mysql_fetch_array($query)) { 
?> 	
<tr>
<td style="text-align:center;"><?php echo $a[id]?></td>
<td style="text-align:center;" ><div class="layui-form"><input type="checkbox"  name="open"  data-id="<?php echo $a[id]?>"  lay-skin="switch" lay-filter="sz" lay-text="是|否" <?php if($a[sz]=="1"){?> checked<?php }?>></div></td>
<td style="text-align:center;"><?php echo $a[name]?></td>
<td style="text-align:center;"><?php echo $a[biaoshi]?></td>
<td style="text-align:center;"><a  class="layui-btn layui-btn-xs layui-btn-normal open_if"   w="100%" h="100%" u="/ht-hzpay-<?php echo $a[id]?>-<?php echo $a[biaoshi]?><?php echo $dshz?>"  n="添加【<?php echo $a[name]?>】配置">添加配置</a></td>
<td style="text-align:center;" ><div class="layui-form"><input type="checkbox"  name="open"  data-id="<?php echo $a[id]?>"  lay-skin="switch" lay-filter="zt" lay-text="查鬼中|都是人" <?php if($a[zt]=="1"){?> checked<?php }?>></div></td>
<td style="text-align:center;">
<?php if($a[lx]==1){?>
默认通道，禁止操作
<?php }else{?>
<a class="layui-btn layui-btn-xs a_menu layui-btn-primary publish_btn" data-id="<?php echo $a[id]?>" data-toggle="modal" data-target="#myPublic"  data-name="<?php echo $a[name]?>"   style="margin-right: 0;font-size:12px;"><i class="layui-icon"></i></a>
<a class="layui-btn layui-btn-xs delete layui-btn-primary"  style="margin-right: 0;font-size:12px;"  onClick="sc('<?php echo $a[id]?>')"><i class="layui-icon"></i></a>
<?php } ?>
</td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
<script type="text/javascript">
layui.use(['form', 'layedit', 'laydate', 'element', 'jquery', 'layer'], function(){
var form = layui.form
,layer   = layui.layer
,layedit = layui.layedit
,element = layui.element
,$= layui.jquery
,laydate = layui.laydate;
form.on('switch(sz)', function (data) {
var zt = this.checked ? 1 : 0,
id = $(this).attr('data-id');
if(zt=='1'){
tip='设置为主通道吗？';
}else{
tip='取消主通道吗？';
}
layer.confirm("确认要" +tip , { title: "确认" }, function (index) {
layer.close(index);
var index = layer.load(3, {
shade: [0.1,'#fff'] 
});
$.ajax({
type : "post",
url : "/htpost<?php echo $dshz?>",
dataType: "json",  
async: true,
data: {id: id,lx:'hzpaysz',zt:zt},
timeout: 10000 ,
success : function(data){
if(data.zt=='1'){  
layer.closeAll('loading');
layer.msg('设置成功');
location.reload();
}else{
layer.closeAll('loading');
layer.msg(data.msg);
location.reload();
} 
},
error:function(){
}
});
}); 
});
form.on('switch(zt)', function (data) {
var zt = this.checked ? 1 : 0,
id = $(this).attr('data-id');
if(zt=='1'){
tip='查鬼吗？';
}else{
tip='恢复人吗？';
}
layer.confirm("确认要" +tip , { title: "确认" }, function (index) {
layer.close(index);
var index = layer.load(3, {
shade: [0.1,'#fff'] 
});
$.ajax({
type : "post",
url : "/htpost<?php echo $dshz?>",
dataType: "json",  
async: true,
data: {id: id,lx:'hzpayzt',zt:zt},
timeout: 10000 ,
success : function(data){
if(data.zt=='1'){  
layer.closeAll('loading');
layer.msg('设置成功');
location.reload();
}else{
layer.closeAll('loading');
layer.msg(data.msg);
location.reload();
} 
},
error:function(){
}
});
}); 
});
});
function sc(id) {
layer.confirm("确认要删除吗，删除后不能恢复", { title: "确认" }, function (index) {
layer.close(index);
var index = layer.load(3, {
shade: [0.1,'#fff'] 
});
$.ajax({
type : "post",
url : "/htpost<?php echo $dshz?>",
dataType: "json",  
async: true,
data: {id: id,lx:'hzpaysc'},
timeout: 10000 ,
success : function(data){
if(data.zt=='1'){  
layer.closeAll('loading');
layer.msg('删除成功');
location.reload();
} 
},
error:function(){
}
});
}); 
}
</script>
<script type="text/javascript">
$('.pub_btn').on('click', function () {
})
$(function () {
$("#pub_btn").click(function () {
var name = $("#name").val();
var biaoshi = $("#biaoshi").val();
if (name == '') {
layer.msg('通道名称不能为空');
return false;
}
if (biaoshi == '') {
layer.msg('通道标识不能为空');
return false;
}
var index = layer.load(3, {
shade: [0.1,'#fff'] 
});
$.ajax({
type : "post",
url : "/htpost<?php echo $dshz?>",
dataType: "json",  
async: true,
data: {name:name,biaoshi:biaoshi,lx: 'hzpayadd'},
timeout: 10000 ,
success : function(data){
if(data.zt=='1'){  
layer.closeAll('loading');
layer.msg('添加成功');
location.reload();
}else{
layer.closeAll('loading');
layer.msg(data.msg);
location.reload();
} 
},
error:function(){
}
});
});
})
<?php if($count =="0"){?>
<?php }else{?>
$(function () {
$("#publish_btn").click(function () {
var id = $("#recipient-id").val();
var name = $("#recipient-name").val();
if (name == '') {
layer.msg('通道名称不能为空');
return false;
}
var index = layer.load(3, {
shade: [0.1,'#fff'] 
});
$.ajax({
type : "post",
url : "/htpost<?php echo $dshz?>",
dataType: "json",  
async: true,
data: {id:id,name:name,lx: 'hzpayxg'},
timeout: 10000 ,
success : function(data){
if(data.zt=='1'){  
layer.closeAll('loading');
layer.msg('更新成功');
location.reload();
}else{
layer.closeAll('loading');
layer.msg(data.msg);
location.reload();
} 
},
error:function(){
}
});
});
})
$('.publish_btn').on('click', function () {
$('#recipient-id').val($(this).data('id'));
$('#recipient-name').val($(this).data('name'));
})
$(function() {
$('.open_if').on('click', function () {
var u = $(this).attr('u');
var w = $(this).attr('w');
var h = $(this).attr('h');
var n = $(this).attr('n');
layer.open({
type: 2,
title: n,
shadeClose: true,
area: [w, h],
content: u
});
});
});
<?php }?>
</script>
<div class="modal fade layui-form" id="myPublic2" tabindex="-1" role="dialog" aria-labelledby="myPublicLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="myModalLabel">添加通道</h4>
</div>
<div class="modal-body">
<div class="form-group">
<label  class="control-label">通道名称</label>
<input type="text"  class="layui-input" id="name" placeholder="输入通道名称" required >
</div>
<div class="form-group">
<label  class="control-label">通道标识</label>
<input type="text"  class="layui-input" id="biaoshi" placeholder="请输入通道标识" required >
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
<button type="button" id="pub_btn" class="btn btn-primary">确认</button>
</div>
</div>
</div>
</div>
</div>
<?php if($count =="0"){?>
<?php }else{?>
<div class="modal fade layui-form" id="myPublic" tabindex="-1" role="dialog" aria-labelledby="myPublicLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="myModalLabel">修改通道</h4>
</div>
<div class="modal-body">
<input type="hidden" name="id" class="form-control" id="recipient-id">
<div class="form-group">
<label  class="control-label">通道名称</label>
<input type="text" name="name" class="layui-input" id="recipient-name"  required="required">
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
<button type="button" id="publish_btn" class="btn btn-primary">确认</button>
</div>
</div>
</div>
</div>
</div>
<?php }?>
</body>
</html>