shenzhipeng 3 years ago
parent
commit
8700495bb2

+ 25 - 0
application/lib/data/adminAction.php

@@ -342,6 +342,12 @@ class AdvertAdminAction extends BaseAction{
 			return $result;
 		}
 
+		public function deleteBatchSmsUserGroup($id_array,$uid){
+			$sql    = "delete  from ly_sms_user_group  where id in ($id_array) and uid='$uid' ";
+			$result = $this->getDbEntity()->query($sql);
+			return $result;
+		}
+
 		//普通发送插入日志表  普通邮件发送日志表
 		public function inserEmail1Log($data){
 			$sql    = "insert into ly_send_email1_log(to_user,subject,content,replay_to,`time`,message,uid) values
@@ -430,6 +436,13 @@ class AdvertAdminAction extends BaseAction{
 			return $result;
 		}
 
+		public function add_sms_user_group($data){
+			$sql    = "insert into ly_sms_user_group(uid,`name`)
+					values('{$data['uid']}','{$data['name']}')";
+			$result = $this->getDbEntity()->insert_sql($sql);
+			return $result;
+		}
+
 		//查询某个用户分组
 		public function select_one_user_group($id,$uid){
 			$sql    = "select * from ly_user_group where id='$id' and uid='$uid'";
@@ -451,6 +464,12 @@ class AdvertAdminAction extends BaseAction{
 			return $result[0];
 		}
 
+		public function select_usergroup_byName($group_name,$uid){
+			$sql    = "select * from ly_sms_user_group where name='$group_name' and uid='$uid'";
+			$result = $this->getDbEntity()->query($sql);
+			return $result[0];
+		}
+
 
 		//修改用户分组
 		public function update_user_group($data, $id,$uid){
@@ -489,6 +508,12 @@ class AdvertAdminAction extends BaseAction{
 			return $result;
 		}
 
+		public function deleteSmsUserGroupMsg($where){
+			$sql  = " delete from ly_sms_user_group where $where";
+			$result = $this->getDbEntity()->query($sql);
+			return $result;
+		}
+
 
 		//查询退信用户是否存在
 		public function select_ndr_user($where,$email){

+ 124 - 0
application/module/ctrl/User_smsgroup_adminAction.class copy.php

@@ -0,0 +1,124 @@
+<?php 
+
+/**
+ * 客户分组
+ */
+
+require_once( ONU_ROOT . 'application/module/ctrl/Action.class.php');
+require_once ( ONU_ROOT . 'application/lib/data/adminAction.php');
+
+class User_smsgroup_adminAction extends Action{
+	
+	public function __construct(){
+		parent::__construct();
+		if(empty($_SESSION['mds_user'])){
+			header("Location:/?a=index&m=admin_login");
+			exit();
+		}
+	}
+	
+	function index(){
+		
+		$admin = new AdvertAdminAction();
+		$where = "where uid='{$_SESSION['user_infos']['id']}'";
+		$uname = $_SESSION['user_infos']['uname'];
+		
+		$info           = $_REQUEST['info'];
+		$error			= $_REQUEST['error'];
+
+		$list  = $admin->select_sms_user_group($where);
+		
+		$this->assign('info',$info);
+		$this->assign('error',$error);
+		$this->assign('list',$list);
+		$this->assign('uname',$uname);
+		$this->display('index.html');
+	}
+	
+	
+	function add(){
+		$admin = new AdvertAdminAction();
+		$data['uid'] = $_SESSION['user_infos']['id'];
+		$data['name'] = trim($_POST['name']);
+
+		if(!empty($_POST['name']) ){
+
+			$is_exist = $admin->select_usergroup_byName($data['name'],$data['uid']);
+			if(!empty($is_exist)){
+				$info = "该客户分组名已存在";
+				header("Location:/?a=user_smsgroup_admin&m=index&info=$info");
+				exit();
+			}else{
+				$add = $admin->add_sms_user_group($data);
+				if($add){
+					$info = "添加客户分组成功";
+					header("Location:/?a=user_smsgroup_admin&m=index&info=$info");
+					exit();
+				}else{
+					$info = "添加客户分组失败";
+				}
+			}
+
+		}else{
+			$info = "客户分组名称不能为空";
+		}
+		$this->assign('info',$info);
+		$this->display('add.html');
+	}
+	
+	
+	public function delete(){
+
+		$admin = new AdvertAdminAction();
+
+		$id	   = $_REQUEST['id'];
+		$uid   = $_SESSION['user_infos']['id'];
+		$group_name = trim($_REQUEST['group_name']);
+
+		if(!empty($id)){
+			$where = " uid = '$uid' and id='$id'";
+			$delete = $admin->deleteSmsUserGroupMsg($where);
+
+			$info = "删除客户分组成功";
+		}else{
+			$error = "删除客户分组失败";
+		}
+
+		header("Location:/?a=user_smsgroup_admin&m=index&info=$info&error=$error");
+		exit();
+	}
+
+
+	//批量删除用户分组
+	public function batch_delete(){
+		$admin = new AdvertAdminAction();
+		$uid   = $_SESSION['user_infos']['id'];
+		$id_array = $_POST['id_array'];
+		$count    = count($id_array);
+
+		if($count==1){
+			$id = $id_array[0];
+			$where = " uid = '$uid' and id='$id'";
+
+			$delete = $admin->deleteSmsUserGroupMsg($where);
+
+			$info = "删除成功";
+			header("Location:/?a=user_smsgroup_admin&m=index&info=$info");
+			exit();
+
+		}else if($count>1){
+			$in_array = implode(',',$id_array);
+
+			$delete = $admin->deleteBatchSmsUserGroup($in_array,$uid);
+
+			$info = "删除成功";
+			header("Location:/?a=user_smsgroup_admin&m=index&info=$info");
+			exit();
+		}
+
+	}
+
+	//end
+
+}
+?>

+ 45 - 0
application/module/view/user_smsgroup_admin/add.html

@@ -0,0 +1,45 @@
+<{include file='../public/admin_header.html'}>
+<{include file='../public/admin_navi.html'}>
+<!-- Right side column. Contains the navbar and content of the page -->
+<aside class="right-side">
+	<!-- Content Header (Page header) -->
+	<section class="content-header">
+		<h1>
+			添加短信客户分组
+			<small>Control panel</small>
+		</h1>
+		<ol class="breadcrumb">
+			<li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
+			<li class="active">Blank page</li>
+		</ol>
+	</section>
+
+	<!-- Main content -->
+	<section class="content">
+
+		<form method="post" action="" id="to_add">
+			客户分组名称:<input type="text" name="name" id="name" >
+			<input type="button" class="btn btn-info" onclick="to_submit();" value="确定"   />
+		</form>
+
+
+	</section><!-- /.content -->
+</aside><!-- /.right-side -->
+</div><!-- ./wrapper -->
+
+<script>
+	$('#treeview9').addClass('active');
+	$(".user_group_left").addClass('active');
+
+	function to_submit(){
+		var name = $('#name').val();
+		if(name==''){
+			alert("请输入客户分组名称");
+		}else{
+			$("#to_add").submit();
+		}
+	}
+</script>
+
+</body>
+</html>

+ 131 - 0
application/module/view/user_smsgroup_admin/index.html

@@ -0,0 +1,131 @@
+<{include file='../public/admin_header.html'}>
+<{include file='../public/admin_navi.html'}>
+<!-- Right side column. Contains the navbar and content of the page -->
+<aside class="right-side">
+	<!-- Content Header (Page header) -->
+	<section class="content-header">
+		<h1>
+			短信客户分组列表
+			<small>Control panel</small>
+		</h1>
+		<ol class="breadcrumb">
+			<li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
+			<li class="active">Blank page</li>
+		</ol>
+	</section>
+
+	<!-- Main content -->
+	<section class="content">
+
+		<{if $info}>
+		<div   class="alert alert-success"><{$info}></div>
+		<{/if}>
+
+		<{if $error}>
+		<div   class="alert alert-danger alert-dismissable"><{$error}></div>
+		<{/if}>
+
+		<div id='main' class="form-actions">
+
+			<a href="/?a=user_smsgroup_admin&m=add" style="font-weight:bold;text-decoration:underline;">添加客户分组</a>
+
+			<form id="batch_delete" method="post" action="/?a=user_smsgroup_admin&m=batch_delete">
+			<input class="btn btn-warning" onclick="toSubmit();" value="批量删除" style="float:right;width:200px;margin-bottom:20px;"  />
+
+
+			<table class="table table-bordered" style="margin-top:15px;clear:both;">
+				<tr>
+					<th style="width:80px;"><input type="checkbox"  id="check-all" />&nbsp;&nbsp;全选</th>
+					<th>ID</th>
+					<th >客户分组名称</th>
+					<th >创建人</th>
+					<th >添加时间</th>
+					<th>操作</th>
+
+				</tr>
+
+				<{foreach from=$list item=item}>
+				<tr>
+					<td>
+						<input type="checkbox"   name="id_array[]" value="<{$item.id}>" />
+					</td>
+					<td><{$item.id}></td>
+					<td><{$item.name}></td>
+					<td><{$uname}></td>
+					<td><{$item.created_at}></td>
+					<td>
+						<a  onclick="to_delete('<{$item.name}>','<{$item.id}>');" style="margin-left:50px;text-align:right;cursor:pointer;" >删除</a>
+					</td>
+				</tr>
+				<{/foreach}>
+			</table>
+			</form>
+
+		</div>
+
+		<script src="static/AdminLTE/js/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.min.js" type="text/javascript"></script>
+		<script src="static/AdminLTE/js/plugins/iCheck/icheck.min.js" type="text/javascript"></script>
+		<link href="static/AdminLTE/css/iCheck/minimal/blue.css" rel="stylesheet" type="text/css" />
+		<link href="static/AdminLTE/css/daterangepicker/daterangepicker-bs3.css" rel="stylesheet" type="text/css" />
+		<script src="static/AdminLTE/js/plugins/daterangepicker/daterangepicker.js" type="text/javascript"></script>
+		<script type="text/javascript">
+			$(function() {
+
+				"use strict";
+
+				//iCheck for checkbox and radio inputs
+				$('input[type="checkbox"]').iCheck({
+					checkboxClass: 'icheckbox_minimal-blue',
+					radioClass: 'iradio_minimal-blue'
+				});
+
+				//When unchecking the checkbox
+				$("#check-all").on('ifUnchecked', function(event) {
+					//Uncheck all checkboxes
+					$("input[type='checkbox']", ".table-bordered").iCheck("uncheck");
+				});
+				//When checking the checkbox
+				$("#check-all").on('ifChecked', function(event) {
+					//Check all checkboxes
+					$("input[type='checkbox']", ".table-bordered").iCheck("check");
+				});
+
+			});
+		</script>
+
+		<script>
+			function toSubmit(){
+				var n = $("input:checked").length;
+
+				if (n<=1) {
+					alert("请选择要批量删除的黑名单吗");
+				}else{
+					if(confirm("确定要删除吗?")){
+						$('#batch_delete').submit();
+					}
+				}
+			}
+		</script>
+
+	</section><!-- /.content -->
+</aside><!-- /.right-side -->
+</div><!-- ./wrapper -->
+
+
+
+<script>
+	$('#treeview9').addClass('active');
+	$(".user_group_left").addClass('active');
+
+	function to_delete(name,id){
+		if(confirm("确定删除"+name)){
+			window.location.href="/?a=user_smsgroup_admin&m=delete&id="+id+"&group_name="+name;
+		}
+	}
+</script>
+
+
+
+
+</body>
+</html>

+ 45 - 0
application/module/view/user_smsgroup_admin/update.html

@@ -0,0 +1,45 @@
+<{include file='../public/admin_header.html'}>
+<{include file='../public/admin_navi.html'}>
+<!-- Right side column. Contains the navbar and content of the page -->
+<aside class="right-side">
+	<!-- Content Header (Page header) -->
+	<section class="content-header">
+		<h1>
+			编辑短信客户分组
+			<small>Control panel</small>
+		</h1>
+		<ol class="breadcrumb">
+			<li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
+			<li class="active">Blank page</li>
+		</ol>
+	</section>
+
+	<!-- Main content -->
+	<section class="content">
+
+		<form method="post" action="" id="to_add">
+			客户分组名称:<input type="text" name="name" id="name"  value="<{$one_info.name}>">
+			<input type="button" class="btn btn-info" onclick="to_submit();" value="确定"   />
+		</form>
+
+
+	</section><!-- /.content -->
+</aside><!-- /.right-side -->
+</div><!-- ./wrapper -->
+
+<script>
+	$('#treeview9').addClass('active');
+	$(".user_group_left").addClass('active');
+
+	function to_submit(){
+		var name = $('#name').val();
+		if(name==''){
+			alert("请输入客户分组名称");
+		}else{
+			$("#to_add").submit();
+		}
+	}
+</script>
+
+</body>
+</html>