mailtpl.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. namespace WY\app\controller\derpay;
  3. use WY\app\libs\Controller;
  4. if (!defined('WY_ROOT')) {
  5. exit;
  6. }
  7. class mailtpl extends CheckAdmin
  8. {
  9. public function index()
  10. {
  11. $lists = $this->model()->select()->from('mailtpl')->fetchAll();
  12. $data = array('title' => '邮件模板', 'lists' => $lists);
  13. $this->put('mailtpl.php', $data);
  14. }
  15. public function save()
  16. {
  17. $cname = $this->req->post('cname');
  18. $title = $this->req->post('title');
  19. $content = $this->req->post('content');
  20. $is_state = $this->req->post('is_state');
  21. if ($cname && $title && $content) {
  22. $data = array('cname' => $cname, 'title' => $title, 'content' => $content, 'is_state' => $is_state, 'addtime' => time());
  23. if ($this->model()->from('mailtpl')->insertData($data)->insert()) {
  24. $this->put('woodyapp.php', array('msg' => '设置保存成功', 'url' => $this->dir . 'mailtpl'));
  25. exit;
  26. }
  27. }
  28. $this->put('woodyapp.php', array('msg' => '保存失败'));
  29. }
  30. public function edit()
  31. {
  32. $id = isset($this->action[3]) ? intval($this->action[3]) : 0;
  33. $data = $this->model()->select()->from('mailtpl')->where(array('fields' => 'id=?', 'values' => array($id)))->fetchRow();
  34. $data += array('title' => '模板编辑');
  35. $this->put('mailtpledit.php', $data);
  36. }
  37. public function editsave()
  38. {
  39. $id = isset($this->action[3]) ? intval($this->action[3]) : 0;
  40. $cname = $this->req->post('cname');
  41. $title = $this->req->post('title');
  42. $content = $this->req->post('content');
  43. $is_state = $this->req->post('is_state');
  44. if ($id && $cname && $title && $content) {
  45. $data = array('cname' => $cname, 'title' => $title, 'content' => $content, 'is_state' => $is_state);
  46. if ($this->model()->from('mailtpl')->updateSet($data)->where(array('fields' => 'id=?', 'values' => array($id)))->update()) {
  47. $this->put('woodyapp.php', array('msg' => '设置保存成功', 'url' => $this->dir . 'mailtpl'));
  48. exit;
  49. }
  50. }
  51. $this->put('woodyapp.php', array('msg' => '保存失败'));
  52. }
  53. public function del()
  54. {
  55. $id = $this->req->get('id');
  56. if ($id) {
  57. if ($this->model()->from('mailtpl')->where(array('fields' => 'id=?', 'values' => array($id)))->delete()) {
  58. echo json_encode(array('status' => 1));
  59. exit;
  60. }
  61. }
  62. echo json_encode(array('status' => 0));
  63. exit;
  64. }
  65. }