Sms_template_adminAction.class.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. <?php
  2. /***
  3. * User: jun_hy
  4. * Date: 2022/7/2
  5. * Time: 8:39
  6. * 邮件模版管理
  7. */
  8. require_once( ONU_ROOT . 'application/module/ctrl/Action.class.php');
  9. require_once ( ONU_ROOT . 'application/lib/data/adminAction.php');
  10. class Sms_template_adminAction extends Action{
  11. public function __construct(){
  12. parent::__construct();
  13. if(empty($_SESSION['mds_user'])){
  14. header("Location:/?a=index&m=admin_login");
  15. exit();
  16. }
  17. // $this->checkAdministratorRight('3');
  18. }
  19. function index(){
  20. require_once (ONU_ROOT . "frame/Page.class.php");
  21. $admin = new AdvertAdminAction();
  22. $where = "where uid='{$_SESSION['user_infos']['id']}' and type=1 ";
  23. $page = $_REQUEST['page']?$_REQUEST['page']:1;
  24. $pageSize = 5;
  25. $n = ($page-1)*$pageSize;
  26. $pa = "";//查询参数
  27. $limit = " $n,$pageSize";
  28. $info = $_REQUEST['info'];
  29. $error = $_REQUEST['error'];
  30. $uname = $_SESSION['user_infos']['uname'];
  31. $list = $admin->select_smstm_list($where,$limit);
  32. $all_total = $admin->select_smstm_count($where);
  33. $p = new Page($all_total,$pageSize,$pa);
  34. $pp = $p->fpage();
  35. $status_array = array(
  36. '1' => '开启',
  37. '2' => '禁用',
  38. );
  39. $this->assign('status_array',$status_array);
  40. $this->assign('info',$info);
  41. $this->assign('error',$error);
  42. $this->assign('page',$page);
  43. $this->assign("show",$pp);
  44. $this->assign('list',$list);
  45. $this->assign('uname',$uname);
  46. $this->display('index.html');
  47. }
  48. function add(){
  49. $admin = new AdvertAdminAction();
  50. // $_POST['msg_content'] = str_replace("\n","<br/>",$_POST['msg_content']);
  51. $msg_content = $_POST['sms_content'];
  52. $data['uid'] = $_SESSION['user_infos']['id'];
  53. $data['msg_title'] = addslashes($_POST['msg_title']);
  54. $data['msg_content'] = addslashes($msg_content);
  55. $data['status'] = $_POST['status'];
  56. $data['add_time'] = time();
  57. $data['update_time'] = time();
  58. $data['type'] = 1;
  59. if($_POST['msg_content']|| $_POST['msg_title']){
  60. if(!empty($data['msg_title']) && !empty($data['msg_content']) ){
  61. $add = $admin->add_smstm_msg($data);
  62. if($add){
  63. $info = "添加短信模板成功";
  64. header("Location:/?a=sms_template_admin&m=index&info=$info");
  65. exit();
  66. }else{
  67. $info = "添加失败";
  68. }
  69. }else{
  70. $info = "模板标题、内容均不能为空";
  71. }
  72. }
  73. $this->assign('data',$data);
  74. $this->assign('info',$info);
  75. $this->display('add.html');
  76. }
  77. function update(){
  78. $admin = new AdvertAdminAction();
  79. $id = $_REQUEST['id'];
  80. //$one_info = $admin->select_onesms_template($id);
  81. // $one_info['msg_content'] = str_replace("<br/>","\n",$one_info['msg_content']);
  82. // $_POST['msg_content'] = str_replace("\n","<br/>",$_POST['msg_content']);
  83. $msg_content = addslashes($_POST['sms_content']);
  84. $data['msg_title'] = addslashes($_POST['msg_title']);
  85. $data['msg_content'] = $msg_content;
  86. $data['status'] = $_POST['status'];
  87. $data['update_time'] = time();
  88. if($_POST['msg_title'] || $_POST['msg_content']){
  89. if(!empty($data['msg_title']) && !empty($data['msg_content']) ){
  90. $update = $admin->update_smstm_msg($data, $id,$_SESSION['user_infos']['id']);
  91. if($update){
  92. $info = "修改短信模板成功";
  93. header("Location:/?a=sms_template_admin&m=index&info=$info");
  94. exit();
  95. }else{
  96. $info = "修改失败";
  97. }
  98. }else{
  99. $info = "模板标题、内容均不能为空";
  100. }
  101. }
  102. $one_info = $admin->select_onesms_template($id);
  103. // $one_info['msg_content'] = str_replace("<br/>","\n",$one_info['msg_content']);
  104. // $one_info['msg_content'] = htmlspecialchars(stripslashes($one_info['msg_content']));
  105. $this->assign('id',$id);
  106. $this->assign('one_info',$one_info);
  107. $this->assign('info',$info);
  108. $this->display('update.html');
  109. }
  110. //删除就是改状态为禁用
  111. public function delete(){
  112. $admin = new AdvertAdminAction();
  113. $id = $_REQUEST['id'];
  114. $status = $_REQUEST['status'];
  115. if(!empty($id)){
  116. $delete = $admin->deleteSmsTemplate($status,$id,$_SESSION['user_infos']['id']);
  117. $info = "禁用成功";
  118. }else{
  119. $error = "禁用失败";
  120. }
  121. header("Location:/?a=sms_template_admin&m=index&info=$info&error=$error");
  122. exit();
  123. }
  124. //end class
  125. }