EduClassBookingAction.class.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <?php
  2. class EduClassBookingAction extends CommonAction
  3. {
  4. public function index()
  5. {
  6. $map = array();
  7. $title = strim($_REQUEST['title']);
  8. if (!empty($title)) {
  9. $map['title'] = array('like', '%' . $title . '%');
  10. }
  11. $this->assign("default_map", $map);
  12. parent::index();
  13. }
  14. public function add()
  15. {
  16. $org_id = intval($_REQUEST['org_id']);
  17. $user_id = M('EduOrg')->where("id=" . $org_id)->getField("user_id");
  18. $this->assign('user_id', $user_id);
  19. $this->display();
  20. }
  21. public function edit()
  22. {
  23. $id = intval($_REQUEST ['id']);
  24. $condition['id'] = $id;
  25. $vo = M(MODULE_NAME)->where($condition)->find();
  26. $this->assign('vo', $vo);
  27. $this->display();
  28. }
  29. public function insert()
  30. {
  31. B('FilterString');
  32. $data = M(MODULE_NAME)->create();
  33. //开始验证有效性
  34. $this->assign("jumpUrl", u(MODULE_NAME . "/add"));
  35. if (!check_empty($data['title'])) {
  36. $this->error("请输入课程标题");
  37. }
  38. // 更新数据
  39. $log_info = $data['title'];
  40. $list = M(MODULE_NAME)->add($data);
  41. if (false !== $list) {
  42. //成功提示
  43. save_log($log_info . L("INSERT_SUCCESS"), 1);
  44. $this->success(L("INSERT_SUCCESS"));
  45. } else {
  46. //错误提示
  47. save_log($log_info . L("INSERT_FAILED"), 0);
  48. $this->error(L("INSERT_FAILED"));
  49. }
  50. }
  51. public function update()
  52. {
  53. B('FilterString');
  54. $data = M(MODULE_NAME)->create();
  55. $log_info = M(MODULE_NAME)->where("id=" . intval($data['id']))->getField("title");
  56. //开始验证有效性
  57. $this->assign("jumpUrl", u(MODULE_NAME . "/edit", array("id" => $data['id'])));
  58. if (!check_empty($data['title'])) {
  59. $this->error("请输入课程标题");
  60. }
  61. $list = M(MODULE_NAME)->save($data);
  62. if (false !== $list) {
  63. //成功提示
  64. save_log($log_info . L("UPDATE_SUCCESS"), 1);
  65. $this->success(L("UPDATE_SUCCESS"));
  66. } else {
  67. //错误提示
  68. save_log($log_info . L("UPDATE_FAILED"), 0);
  69. $this->error(L("UPDATE_FAILED"), 0, $log_info . L("UPDATE_FAILED"));
  70. }
  71. }
  72. public function delete()
  73. {
  74. //删除指定记录
  75. $ajax = intval($_REQUEST['ajax']);
  76. $id = $_REQUEST ['id'];
  77. if (isset ($id)) {
  78. $condition = array('id' => array('in', explode(',', $id)));
  79. $rel_data = M(MODULE_NAME)->where($condition)->findAll();
  80. foreach ($rel_data as $data) {
  81. $info[] = $data['title'];
  82. }
  83. if ($info) {
  84. $info = implode(",", $info);
  85. }
  86. $list = M(MODULE_NAME)->where($condition)->delete();
  87. if ($list !== false) {
  88. save_log($info . l("DELETE_SUCCESS"), 1);
  89. $this->success(l("DELETE_SUCCESS"), $ajax);
  90. } else {
  91. save_log($info . l("DELETE_FAILED"), 0);
  92. $this->error(l("DELETE_FAILED"), $ajax);
  93. }
  94. } else {
  95. $this->error(l("INVALID_OPERATION"), $ajax);
  96. }
  97. }
  98. }