You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

122 lines
4.0 KiB

  1. <?php
  2. defined('BASEPATH') OR exit('No direct script access allowed');
  3. require APPPATH . '/libraries/REST_Controller.php';
  4. class Management extends REST_Controller
  5. {
  6. /****************************************************************************
  7. * 공용 순서변경
  8. ***************************************************************************/
  9. function sort_post()
  10. {
  11. $key = $this->input->post('key', TRUE);
  12. $sort_idx = $this->input->post("sort_order", TRUE);
  13. $table = $this->input->post('table', TRUE);
  14. $sort_col = $this->input->post('sort', TRUE);
  15. if(empty($key) OR empty($table) or empty($sort_col))
  16. $this->response(array('message'=>'잘못된 접근입니다.'));
  17. $update_array = array();
  18. for($i=1; $i<=count($sort_idx); $i++)
  19. {
  20. $update_array[] = array(
  21. $key => $sort_idx[$i-1],
  22. $sort_col => $i
  23. );
  24. }
  25. $this->db->update_batch($table, $update_array, $key);
  26. }
  27. /**
  28. * 팝업 목록
  29. */
  30. function popups_get() {
  31. $page_rows = $this->input->get('take', TRUE, 15);
  32. $start = $this->input->get('skip', TRUE);
  33. $this->db
  34. ->select('SQL_CALC_FOUND_ROWS P.*, M.mem_nickname AS upd_username', FALSE)
  35. ->from('popup AS P')
  36. ->join('member AS M','M.mem_idx=P.upd_user','inner')
  37. ->where('pop_status', 'Y')
  38. ->order_by('pop_idx DESC')
  39. ->limit($page_rows, $start);
  40. $result = $this->db->get();
  41. $return['lists'] = $result->result_array();
  42. $return['totalCount'] = (int)$this->db->query("SELECT FOUND_ROWS() AS cnt")->row(0)->cnt;
  43. foreach($return['lists'] as $i=>&$row)
  44. {
  45. $row['nums'] = $return['totalCount'] - $i - $start;
  46. $row['pop_state'] = (strtotime($row['pop_start']) <= time() && strtotime($row['pop_end']) >= time())?'표시중':'미표시중';
  47. }
  48. $this->response($return, 200);
  49. }
  50. /**
  51. * 팝업 삭제
  52. */
  53. function popups_delete()
  54. {
  55. $pop_idx = $this->delete('pop_idx', TRUE);
  56. $mem_idx = $this->member->is_login();
  57. if(empty($pop_idx)) $this->response('잘못된 접근입니다.', 400);
  58. $data['upd_datetime'] = date('Y-m-d H:i:s');
  59. $data['upd_user'] = $mem_idx;
  60. $data['pop_status'] = 'N';
  61. $this->db->where('pop_idx', $pop_idx);
  62. $this->db->update('popup', $data);
  63. }
  64. /**
  65. * 사이트맵 목록
  66. */
  67. function sitemaps_get()
  68. {
  69. $page_rows = $this->input->get('take', TRUE, 15);
  70. $start = $this->input->get('skip', TRUE);
  71. $this->db
  72. ->select('SQL_CALC_FOUND_ROWS S.*, M.mem_nickname AS upd_username', FALSE)
  73. ->from('sitemap AS S')
  74. ->join('member AS M','M.mem_idx=S.upd_user','inner')
  75. ->order_by('sit_idx DESC')
  76. ->limit($page_rows, $start);
  77. $result = $this->db->get();
  78. $return['lists'] = $result->result_array();
  79. $return['totalCount'] = (int)$this->db->query("SELECT FOUND_ROWS() AS cnt")->row(0)->cnt;
  80. $this->response($return, 200);
  81. }
  82. function sitemaps_delete()
  83. {
  84. $sit_idx = $this->delete('sit_idx', TRUE);
  85. if(empty($sit_idx)) $this->response(array('message'=>'잘못된 접근입니다.'), 400);
  86. $this->db->where('sit_idx', $sit_idx)->delete('sitemap');
  87. }
  88. /**
  89. * 공용 에디트
  90. */
  91. function updates_post()
  92. {
  93. $table = $this->post('table', TRUE);
  94. $key_column = $this->post('key_column', TRUE);
  95. $key = $this->post('key', TRUE);
  96. $values = $this->post('values', TRUE);
  97. if(empty($table) OR empty($key_column) OR empty($key)) $this->response(array('message'=>'잘못된 접근입니다.'), 400);
  98. $values['upd_datetime'] = date('Y-m-d H:i:s');
  99. $values['upd_user'] = $this->member->is_login();
  100. $this->db->where($key_column, $key);
  101. $this->db->update($table, $values);
  102. }
  103. }